Utk*_*maz 39 uitabbar ios swift
有没有办法隐藏tabbar并删除剩余的空间(约50px)?
我试过了
self.tabBarController?.tabBar.hidden = true
self.extendedLayoutIncludesOpaqueBars = true
Run Code Online (Sandbox Code Playgroud)
没运气.我看到空白.
小智 60
如果您仍然在隐藏的标签栏下面看到黑色条纹,您是否尝试在此处选择"在不透明条形下延伸边缘"?
还要确保仍然选择Under Bottom Bars.希望能帮助到你!
Ale*_*ano 34
斯威夫特3:
extension UITabBarController {
func setTabBarVisible(visible:Bool, duration: TimeInterval, animated:Bool) {
if (tabBarIsVisible() == visible) { return }
let frame = self.tabBar.frame
let height = frame.size.height
let offsetY = (visible ? -height : height)
// animation
UIViewPropertyAnimator(duration: duration, curve: .linear) {
self.tabBar.frame.offsetBy(dx:0, dy:offsetY)
self.view.frame = CGRect(x:0,y:0,width: self.view.frame.width, height: self.view.frame.height + offsetY)
self.view.setNeedsDisplay()
self.view.layoutIfNeeded()
}.startAnimation()
}
func tabBarIsVisible() ->Bool {
return self.tabBar.frame.origin.y < UIScreen.main.bounds.height
}
}
Run Code Online (Sandbox Code Playgroud)
使用(例如,如果self是UITabBarController):
self.setTabBarVisible(visible: false, duration: 0.3, animated: true)
Run Code Online (Sandbox Code Playgroud)
Swift 2.x:
extension UITabBarController {
func setTabBarVisible(visible:Bool, duration: NSTimeInterval, animated:Bool) {
if (tabBarIsVisible() == visible) { return }
let frame = self.tabBar.frame
let height = frame.size.height
let offsetY = (visible ? -height : height)
// animation
UIView.animateWithDuration(animated ? duration : 0.0) {
self.tabBar.frame = CGRectOffset(frame, 0, offsetY)
self.view.frame = CGRectMake(0, 0, self.view.frame.width, self.view.frame.height + offsetY)
self.view.setNeedsDisplay()
self.view.layoutIfNeeded()
}
}
func tabBarIsVisible() ->Bool {
return self.tabBar.frame.origin.y < UIScreen.mainScreen().bounds.height
}
}
Run Code Online (Sandbox Code Playgroud)
使用:
self.tabBarController?.setTabBarVisible(visible: false, duration: 0.3, animated: true)
Run Code Online (Sandbox Code Playgroud)
JZA*_*ZAU 25
在评论中看到你的截图.我想你可以尝试设置hidesBottomBarWhenPushed为true.
hidesBottomBarWhenPushed = true
Run Code Online (Sandbox Code Playgroud)
或故事板.
当您推送到另一个视图控制器时,它会自动隐藏底栏,并在您返回时再次显示.
Itu*_*ote 10
以编程方式,将其添加到下一个视图控制器以进行快速处理4。
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
tabBarController?.tabBar.isHidden = true
edgesForExtendedLayout = UIRectEdge.bottom
extendedLayoutIncludesOpaqueBars = true
}
Run Code Online (Sandbox Code Playgroud)
并添加背景色
| 归档时间: |
|
| 查看次数: |
30211 次 |
| 最近记录: |