Reputation: 8066
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 ).
Upvotes: 4
Views: 1992
Reputation: 2020
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.
Upvotes: 3
Reputation: 3706
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];
Upvotes: 1