天天看點

IOS 導航欄 設定半透明 跳轉黑邊的問題解決辦法有兩種

今天使用UINavigationController,設定translucent半透明屬性後進去push/pop跳轉,發現頁面在出現和消失的瞬間,導航欄的右邊會出現短暫的黑色陰影。其實以前也發現過這個問題,但是沒要求必須透明我就不設定透明了,也就沒去找怎麼解決。

IOS 導航欄 設定半透明 跳轉黑邊的問題解決辦法有兩種

2016-05-04 10_51_40.gif

仔細調試了半天,發現這個問題不是設定translucent。而是你設定了tabbar的hide bottom bar on push的屬性後跳轉才會出現。

解決辦法有兩種

1.直接在appdelegate裡面的didFinishLaunchingWithOptions方法裡面設定window的背景顔色

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    self.window.backgroundColor = [UIColor whiteColor];


    return YES;
}
           

2.或者建立一個繼承與UITabBarController的子類裡面設定背景顔色

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];

}                

感謝圖拉鼎的文章http://imtx.me/archives/1933.html

文/newbiecoder(簡書作者)

原文連結:http://www.jianshu.com/p/201af7038d3d

著作權歸作者所有,轉載請聯系作者獲得授權,并标注“簡書作者”。

繼續閱讀