I have 1custom UIView
in my default view in viewcontroller.
My need is that if a button is clicked my default main view goes to blur and custom view remains unchanged.
And a button is clicked again the blured view returns to normal effect.
I used the UIBlurEffect
and UIVisualEffectView
for making blur.
But the problem is whole view got blured.
Asked
Active
Viewed 247 times
0

Rajan Maheshwari
- 14,465
- 6
- 64
- 98

Mahin
- 61
- 10
2 Answers
1
Apply it to your view only you want to make it blur. Try it:
UIVisualEffect *MyblurEffect;
MyblurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView;
visualEffectView = [[UIVisualEffectView alloc] initWithEffect:MyblurEffect];
visualEffectView.frame = MyVIEW.bounds;
[MyVIEW addSubview:visualEffectView]; //MyVIEW-> your view
Try with these link: How to apply blur to a UIView?

Community
- 1
- 1

Jamshed Alam
- 12,424
- 5
- 26
- 49
-
I used the same code.I want to make the default view blur. But the problem is my custom view lies on the default view. So if I try to blur main view blur,my custom view is also getting blured because of it lies on the main view. Is there something that removes the UIVisualEffectView from my custom view?UIVisualEffectVIew must subview the main view – Mahin Oct 16 '16 at 11:44
-
Check the link. – Jamshed Alam Oct 16 '16 at 11:52
1
I've not tried the effects views yet, but they look like they participate as good citizens in the view hierarchy. If that's true, then this should work...
// assume aView is the view you want blurred, and
// aSubview is the view you want to remain unblurred
[aSubview removeFromSuperview];
// apply the effect view to aView
[aView addSubview:aSubview];

danh
- 62,181
- 10
- 95
- 136