今天更新的xc9,然后再x上信心滿滿的跑項目,然后就是你懂的,尷尬了一地。
1、狀態欄問題
相信大家都遇到了這個問題,x上的狀態欄高度不一樣。大家可以觀看wwdc介紹這個新特性。
判斷是否為iphone X,可以寫一個擴展。
extension UIDevice {
? ?public func isX() -> Bool {
? ? ? ? if UIScreen.main.bounds.height == 812 {
? ? ? ? ? ? ? ? return true
? ? ? ? ?}
? ? ? ? ?return false
? ? }
}
2、自定義Tabbar問題
自定義tabbar時,在自定義的TabbarController里面實現:
-(void)viewDidAppear:(BOOL)animated{
[superviewDidAppear:animated];
//刪除系統自帶的按鈕
for(UIView*childinself.tabBar.subviews) {
if([childisKindOfClass:[UIControlclass]]) {
[childremoveFromSuperview];
}
}
}
當你覺得ok的時候,發現從tabbar的子控制器push頁面,然后pop回來。tabbar又發生了變化,居然又多了一層。廢話不多說,干貨:
-(void)viewWillLayoutSubviews{
[superviewWillLayoutSubviews];
for(UIView*childinself.tabBar.subviews) {
if([childisKindOfClass:NSClassFromString(@"UITabBarButton")]) {
[childremoveFromSuperview];
}
}
}
ok.補充哈,這兩個方法都寫在自定義的TabbarController.