public protocol NavigationBarNormalStyle {
var titleView: UIToolbar! {get}
var rightButton: UIButton? {get}
}
public extension NavigationBarNormalStyle where Self == UIViewController {
var titleView:UIToolbar {
var titleViewBar = UIToolbar(frame: CGRect(x: 0.0, y: 0.0, width:Self.view.width, height: 44))
titleViewBar.barTintColor = UIColor.whiteColor()
Self.view.addSubview(titleViewBar)
}
}
Self.view.width
is wrong... How to use the vc's property?
You want to access instance properties, but Self
is the class of your object, not the object itself.
Your should write self.view
, etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.