【发布时间】:2018-05-13 10:21:38
【问题描述】:
由于以下问题Why page Push animation Tabbar moving up in the iPhone X,我需要为我的项目使用 UITabBar 的子类。
我不使用故事板。这如何以编程方式完成?
-- 更新--
我的 CustomTabBarController.swift 文件现在看起来像这样:
import UIKit
@objc class customTabBarController: UITabBarController {
override var tabBar: UITabBar {
return customTabBar
}
}
我的 CustomTabBar.swift 文件如下所示:
import UIKit
class customTabBar: UITabBar {
override var frame: CGRect {
get {
return super.frame
}
set {
var tmp = newValue
if let superview = superview, tmp.maxY !=
superview.frame.height {
tmp.origin.y = superview.frame.height - tmp.height
}
super.frame = tmp
}
}
}
但这给了我以下错误:
Cannot convert return expression of type 'customTabBar.Type' to return type 'UITabBar'
【问题讨论】:
标签: ios uitabbarcontroller uitabbar