日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ios 动画 隐藏tabbar_UITabBarViewController 的底部 tabBar 隐藏

發布時間:2023/12/9 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ios 动画 隐藏tabbar_UITabBarViewController 的底部 tabBar 隐藏 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

iOS pushViewController 時候隱藏 TabBar 的可以用@interfaceUIViewController (UINavigationControllerItem)

@property(nonatomic,readonly,strong)UINavigationItem*navigationItem;// Created on-demand so that a view controller may customize its navigation appearance.

@property(nonatomic)BOOL hidesBottomBarWhenPushed __TVOS_PROHIBITED;// If YES, then when this view controller is pushed into a controller hierarchy with a bottom bar (like a tab bar), the bottom bar will slide out. Default is NO.

這是系統提供的 UINavigationViewController 的方法。你只需要在被push 的 UIViewcontroller 的初始化方法中添加這個屬性就行。self.hidesBottomBarWhenPushed = YES;

這樣有2個問題

1. 是做 pushViewController transition 過渡的時候,動畫中會看到 tabBar 被移出去,尤其是被push 的viewController 的背景色反差很大的時候,體驗很差。

2. presentViewController 的時候無法使用這個方法。

解決方法:

自己控制 UITabBarViewController 的 bottom tabBar。setFrame的方法控制。- (void)hideTabBar {

[self setTabBarHidden:YES];

}

- (void)showTabBar {

[self setTabBarHidden:NO];

|}

- (void) setTabBarHidden:(BOOL)hidden {

CGRect screenRect = [[UIScreen mainScreen] bounds];

floatfHeight = screenRect.size.height;

if(UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))

fHeight = screenRect.size.width;

if(!hidden) fHeight -=self.tabBar.frame.size.height;

[UIViewanimateWithDuration:0.25 animations: ^{

for(UIView*view in self.view.subviews) {

if([view isKindOfClass:[UITabBar class]]) {

[view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];

}else{

if(hidden) [viewsetFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];

}

}

}completion:^(BOOLfinished) {

if(!hidden) {

[UIViewanimateWithDuration:0.25animations: ^{

for(UIView*viewinself.view.subviews) {

if(![viewisKindOfClass:[UITabBarclass]])

[viewsetFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];

}

}];

}

}];

}

總結

以上是生活随笔為你收集整理的ios 动画 隐藏tabbar_UITabBarViewController 的底部 tabBar 隐藏的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。