2013-10-23 55 views
37

比較兩個截圖:酒吧半透明的的iOS 7.0.3了

完成在iOS 7.0模擬器

enter image description here

而且一個在iOS 7.0.3 iPhone 4S做:

enter image description here

相同的代碼在這裏,那裏和相同的東西!任何想法爲什麼半透明性在真實設備上消失了?

我有這樣的代碼來模擬它(我知道這可能是尷尬的,不正確的,但是這就是它是):

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應用中的相同行爲。

UPDATE

上的Xcode 5.0.1與iOS 7.0.3模擬器,我們有這個(這是在iOS 7.0模擬器,你可以看到第一個圖像不同):

enter image description here

+1

您是否關閉了iPhone中的輔助功能和動作? – Fogmeister

+0

正如Fogmeister建議的那樣,請檢查[輔助功能>增加對比度]的設置(http://www.macworld.com/article/2048738/get-to-know-ios-7-changes-in-the-settings-app.html ),這會降低半透明度。 –

+0

@Fogmeister不,沒有任何改變。我認爲模擬器上沒有這樣的選項。 –

回答

17

好的,所以在玩過一些顏色後,我設法得到了模糊的類似外觀!

以前,我設置在導航條外觀的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值的,我設法從NAV(和標籤)欄RGB輸出完全一樣的,使用下面的RGBA:

R:4.5 G:61.6 B:98 A:0.65

它看起來不像以前的顏色有魔術比率來獲得新的顏色。

反正我實際上已經拒絕了得到批准,今天下午,與這些新的值已重新提交,以便用戶沒有得到一個醜陋的應用程序:)

希望這有助於二進制文件。

+0

那麼你真的得到這個模糊效果?當我們更改barTintColor的alpha時,我們只是獲得半透明的視圖... – jjxtra

+0

有模糊效果是的。我發現0.5到0.7之間的alpha值似乎給出了最好的模糊結果。我會很快更新我的文章與截圖。 – Mutix

+0

確定alpha顏色的確改變了一些東西,但是移動模糊視圖導致真的很糟糕的閃爍 – jjxtra