2017-10-18 259 views
0

我在低於iOS的11
iOS的11 leftBarButtonItem/rightBarButtonItem位置錯誤

我的代碼是在這裏發現UINavigationBar.height = 56在iOS11UINavigationBar.height = 44

UIBarButtonItem *scanButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"scan_code"] style:UIBarButtonItemStylePlain target:self action:@selector(pushScanController)]; 
self.navigationItem.leftBarButtonItem = scanButton; 

存在位置錯誤在iOS11中。

如圖所示:

enter image description here

enter image description here

我怎樣才能修復這個bug?

回答

0

它看起來像你的問題是通過搜索欄被而不是在按鍵更大的東西造成的。

你可能想嘗試這樣的:

if #available(iOS 11.0, *) { 
    [[self.yourSearchBar.heightAnchor constraintEqualToConstant:44.0] setActive:YES] 
} 

或調查並實施了iOS 11搜索欄的變化。

+0

根據你的代碼,UI顯示還是有點不正常。 另外,在VC下調用另一個VC,會有一個UINavigationBar啓動畫面,因爲下一個VC UINavigationBar.height = 56。所以這樣做還是不太好。 – Eddiegooo