Change the blur effect of the UINavigationBar

I need to implement a UINavigationBar with a custom design, I need to change the inverse image, all colors need to be changed, and the height must be changed.

I know everything that is possible, but I also need to change the blur effect. This should be an easier blur. Is there a way to do this without going into private APIs?

Edit: An image of how it should look (I know the status bar is pixelated, ignore it):

enter image description here

+5
source share
1 answer

UIVisualEffectView will add a transparency and blur effect to iOS 8+ views. A.

Three blur UIBlurEffectStyles are available .

 - (void)addBlurEffect{ CGRect bounds = self.navigationController.navigationBar.bounds; UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]]; visualEffectView.frame = bounds; visualEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self.navigationController.navigationBar addSubview:visualEffectView]; self.navigationController.navigationBar.backgroundColor = [UIColor clearColor]; [self.navigationController.navigationBar sendSubviewToBack:visualEffectView]; } 

For more information about UIVisualEffectView , check out this question on SO .

*************** EDIT FOR iOS 7 ****************

Nicklockwood FXBlurView came to the rescue image for iOS5 , iOS6 , iOS7 .

I am creating a sample project for you that has the desired dynamic blur effect in the navigation bar for iOS7. Follow the guide below to use it in your project.

  • Take a look at AppDelegate.m
  • Here I add the background image to the navigation bar. You can refresh the image in any view manager to get a dynamic blur background image in the navigation bar.
  • There are several properties of FXblurview, such as blurRadius , iterations , tintColor ; which you should read here .

Installation Guide: - https://github.com/nicklockwood/FXBlurView?source=c#installation

The full source code for FXBlurView-master can be found here .

+1
source

Source: https://habr.com/ru/post/1238642/


All Articles