Blurring effect disappeared on iOS 7.1

前端 未结 4 1620
死守一世寂寞
死守一世寂寞 2021-02-04 16:12

For some reason the blur effect is gone from my app on iOS 7.1. I\'m running the same code on a device with iOS 7.0.x and on another with 7.1. Here\'s what I see:

相关标签:
4条回答
  • 2021-02-04 16:42

    Probably the second screenshot is taken from an iPhone 4 ? On the iPhone 4 and iPad 2 blur effect is replaced with a simply sample color with transparency.

    0 讨论(0)
  • 2021-02-04 16:42

    Settings > General > Increase Contrast > Reduce Transparency is probably enabled on the 7.1 device.

    0 讨论(0)
  • 2021-02-04 16:49

    By the way, it's worth noting that the image that you describe as having no blurring/translucency actually does. If you take that snapshot and pump up the contrast, you can see that there actually is something going on in the background. Here is your original "no blurring/translucency image", which I bumped up contrast in Photoshop:

    high contrast

    It's barely visible to the naked eye unless you manipulate the image, but the blurring/translucency is actually there.

    0 讨论(0)
  • 2021-02-04 17:02

    At a glance

    It seems the navigation bar simply doesn't have anymore blur effet since iOS7.1. At least I ran many tests, by doing new app sample, it doesn't have anymore.

    Workaround (work on iOS 7.1)

    Here a sample using FXBlurView

    It's not marvelous but it works fine and it's customizable. My example is certainly not the best.

    Previous solution proposed (doesn't work on iOS7.1)

    Here is my solution to find back a similar effect. It is ok for release it doesn't use private API. But it can have issue with next update of iOS since it rely on inside structure of UINavigationBar.

    Simply do that in your viewDidLoad or where ever you want since it works :

    // First we make the background's navigation bar totally translucent
    self.navigationController.navigationBar.barTintColor = [UIColor clearColor];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor]] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    
    // Then we create UIToolBar, which are still using blur effect
    UIToolbar *tab = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 64)];
    // We add it the barTintColor we want, works the same as since iOS 7.0.3, don't forget alpha value
    tab.barTintColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:0.2];
    
    // And finally we add it to the background view of UINavigationBar... but it can change with future release of iOS. Be aware !
    [[self.navigationController.navigationBar.subviews firstObject] addSubview:tab];
    

    I also advice you to use AutoLayout to constraint the UIToolBar to be always the size of it's parent, for rotations etc... I didn't do it to let the code short and simple.

    Hope it helps you guys !

    0 讨论(0)
提交回复
热议问题