Change Notification Content Extension background color - ios

While developing Notification Content Extension I noticed, it's impossible to change background color to clear color.
I want it looks like background of weather standard app widget.
So, if I change background color of View to clear in IB or by code, it's become white without alpha.
You see that buttons with blurred background and white notification background looks awful. If you have some ideas, please tell me.
Tested on iPhone 6 Plus and iPhone 6s iOS 10 beta 3 and Xcode 8 beta 3.

you can try adding a UIBlurEffect like this:
self.view.backgroundColor = [UIColor clearColor];
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
blurEffectView.frame = self.view.bounds;
blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
blurEffectView.alpha = 0.5;
[self.view insertSubview:blurEffectView atIndex:0];
you can play with background color or with UIBlurEffectStyle to achieve exact thing that you like.

Related

UIPickerView to be same color as navigationBar

I have an app with a UIPickerView that comes on screen when needed. I would like it to be the same color as the default navigationBar which is a little transparent, you can see through it but not enough to obscure what is on the navigationBar.
There may be a simple solution and if there is great! I'm new to the game.
Thanks in advance
So thanks to #ChristianSchorr I used UIVisualEffectView to achieve my goal
UIVisualEffectView *visualEffectView;
UIVisualEffect *blurEffect;
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[self.tableStations addSubview:visualEffectView];
pickerSort.frame = CGRectMake(0,0,originalPickerFrame.size.width,originalPickerFrame.size.height);
visualEffectView.frame = CGRectMake(0,0,originalPickerFrame.size.width,originalPickerFrame.size.height - 64);
Worked for I needed

Blur the image in image view at Background iOS

I want to place the image view on background of window,above the image view i have placed the table view which is transparent.I want image in background is to be blur. thanks..
In iOS 8 you can use UIVisualEffect to blur views
UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];// explore other effects too
UIVisualEffectView *visualEffectView =[[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = YOURFRAME; // set frame
[visualEffectView setAlpha:1.0];// set as you like
[YOURVIEW addSubview:visualEffectView]; //add on your view where you want

How can I make the UIView transparent with wallpaper

Apple's iPod app and Remote app can see the a blurred version of the wallpaper image, as you can see the image below:
I really like this effect, so I tried to set my root view's alpha value, but it did not work.
And I set opaque to NO, but it still didn’t work. It looks just like a black screen:
My question is: Maybe it’s limited for Apple's app use only?
This used to work, but it was never documented, and apparently has been removed from more recent versions of iOS. You can use UIVisualEffectView to blur things in your own app, but you can’t make your app transparent so that you can see the device wallpaper. If you think Apple should add this feature for developers, you should file a bug.
When app get background, use the codes below:
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blur];
[effectView setFrame:self.view.bounds];
[self.view addSubview:effectView];
ADDED
- (void)applicationWillResignActive:(UIApplication *)application {
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blur];
[effectView setFrame:[[UIScreen mainScreen] bounds]];
[[[UIApplication sharedApplication] keyWindow] addSubview:effectView];
}
Tested and works.
Don't forget to remove the effectView when app become active.

Strange blur artefacts with UIVisualEffectView

I have a UIVisualEffectView which is causing some strange artefacts right when it appears. The UIVisualEffectView is added in code after the view loads because it's not available in iOS 7.
Look at the blurred text background over the street view image: http://s.swic.name/Z3UL
The blur takes a good 0.1 seconds to appear, and before that it's just a lower resolution background shining through like the blur hasn't been calculated yet.
Any idea what is going on? I'm adding the blur in awakeFromNib using this code
- (void)addBlurWithColor:(UIColor *)color andStyle:(UIBlurEffectStyle)style andVibrancy:(BOOL)vibrancy
{
if (UIDevice.supportsVisualEffects && NSClassFromString(#"UIVisualEffectView") && !UIAccessibilityIsReduceTransparencyEnabled()) {
self.backgroundColor = color;
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:style];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = self.bounds;
visualEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
NSArray *subviews = self.subviews;
[self addSubview:visualEffectView];
[self sendSubviewToBack:visualEffectView];
if (vibrancy) {
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
[vibrancyEffectView setFrame:self.bounds];
vibrancyEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
for (UIView *subview in subviews) {
[vibrancyEffectView.contentView addSubview:subview];
}
[[visualEffectView contentView] addSubview:vibrancyEffectView];
}
}
}
Edit: The video just has slow animations enabled, the transition is a regular push segue.
Edit2: I get the same strange behaviour if i just drag drop a "UIVisualEffectView with Blur" in Interface Builder, so the code above shouldn't be to blame.
Found the problem, when the view appears I'm reloading the tableview inside [UIView transitionWithView:...] which alters the alpha which apparently is a big no-no when it comes to UIVisualEffectViews!
According to UIVisualEffectView Documentation;
When using the UIVisualEffectView class, avoid alpha values that are
less than 1. Creating views that are partially transparent causes the
system to combine the view and all the associated subviews during an
offscreen render pass. UIVisualEffectView objects need to be combined
as part of the content they are layered on top of in order to look
correct. Setting the alpha to less than 1 on the visual effect view or
any of its superviews causes many effects to look incorrect or not
show up at all.
https://developer.apple.com/library/ios/documentation/uikit/reference/UIVisualEffectView/index.html

iOS 8 Transparent View with non-transparent subviews

I want to place non transparent content on top of a UIImageView. So I have a view with a transparent background which contains all the content. And I've placed it on top of imageview. I've set this view's background color to clearColor but still I can not get the desired effect.
This was clearly possible with iOS 6 SDK , but now I'm trying with iOS 8 SDK which does not give me what I want.
Check this app's screenshot
I'm trying to achieve similar effect (a semi transparent view) with iOS 8 SDK. However I need to set opacity very low value which makes the view almost transparent. All I could achieve was very little transparency (something like alpha 0.9 even I set 0 ).
This can be achieved by Using UIVisualEffect and UIVisualEffectView which are available from iOS 8 on.
This will provide a transparent view, as you said, without affecting the subviews.
Try this
UIVisualEffectView *blurredView =[[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
[blurredView addSubview:self.mySubView];
and you can add your subviews and image views as well.
Add your required views in the order, similar to the below code...
UIImageView* bottomImgView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
bottomImgView.image=[UIImage imageNamed:#"yourImg.png"];
[self.view bottomImgView];
UIView* topTransparentView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
topTransparentView.backgroundColor = [UIColor clearColor];
[bottomImgView addSubview:topTransparentView];
UIView* subView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
subView.backgroundColor = [UIColor blueColor];
[topTransparentView addSubview:subView];

Resources