比较两个屏幕截图:
在iOS 7.0模拟器上完成
在iOS 7.0.3 iPhone 4S上完成的一项:
相同的代码在这里和那里,同样的东西!知道为什么半透明在真实设备上消失了吗?
我有以下代码可以对其进行仿真(我知道它可能很笨拙,不正确,但事实就是这样):
topMenuView = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, 0, self.view.frame.size.width, TOP_BAR_ORIG_HEIGHT)];
topMenuView.clipsToBounds = YES;
UIToolbar *topMenuViewBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, -4, self.view.frame.size.width, TOP_BAR_ORIG_HEIGHT + 4)];
topMenuViewBar.barStyle = UIBarStyleDefault;
topMenuViewBar.barTintColor = [BSFunctions getColorFromHex:@"1ea6ff"];
const CGFloat statusBarHeight = 20;
UIView *underlayView = [[UIView alloc] initWithFrame:CGRectMake(0, -statusBarHeight, topMenuViewBar.frame.size.width, topMenuViewBar.frame.size.height + statusBarHeight)];
[underlayView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[underlayView setBackgroundColor:[BSFunctions getColorFromHex:@"1ea6ff"]];
[underlayView setAlpha:0.36f];
[topMenuViewBar insertSubview:underlayView atIndex:1];
UIView *underlayView2 = [[UIView alloc] initWithFrame:CGRectMake(0, -statusBarHeight, topMenuViewBar.frame.size.width, topMenuViewBar.frame.size.height + statusBarHeight)];
[underlayView2 setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[underlayView2 setBackgroundColor:[BSFunctions getColorFromHex:@"0291ff"]];
[underlayView2 setAlpha:0.36f];
[topMenuViewBar insertSubview:underlayView2 atIndex:2];
[topMenuView addSubview:topMenuViewBar];
[self.view addSubview:topMenuView];
要点是它以前可以在设备上工作!但是在iOS 7.0.3发布之后,它发生了变化。我注意到Facebook和Fitocracy iOS应用程序中的行为相同。
更新
在具有iOS 7.0.3模拟器的Xcode 5.0.1上,我们具有此功能(与您可以看到的iOS 7.0模拟器上的第一张图像不同):
好的,所以在使用了更多颜色之后,我设法获得了类似的模糊外观!
以前,我在导航栏外观上设置了barTintColor,其值如下:
R:17 G:63 B:95 A:1
在iOS <7.0.3中很好,并且导航栏中的输出颜色(具有模糊效果)实际上是:
R:62 G:89 B:109
从iOS 7.0.3开始,barTintColor似乎考虑了我们设置的颜色的Alpha值。这意味着导航栏实际上输出的是纯色17,63,95,并且没有模糊效果。
恢复模糊效果的关键是在barTintColor中设置alpha <1。
经过大量的猜测工作并尝试了不同的RGB值,我设法使用以下RGBA从导航(和选项卡)栏中获得了完全相同的RGB输出:
R:4.5 G:61.6 B:98 A:0.65
看起来没有神奇的比率可以应用于以前的颜色以获得新的颜色。
无论如何,我实际上已经拒绝了今天下午获得批准的二进制文件,并重新提交了这些新值,以便用户不会得到一个丑陋的应用程序:)
希望这可以帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句