Commit 0de308b9 by Daniel Dahan

issue-829: A recomendation to better access the NavigationBar in NavigationItem

parent fa58ac50
...@@ -84,8 +84,16 @@ public class NavigationItem: NSObject { ...@@ -84,8 +84,16 @@ public class NavigationItem: NSObject {
} }
} }
/// An optional reference to the NavigationBar.
public var navigationBar: NavigationBar? { public var navigationBar: NavigationBar? {
return contentView.superview?.superview as? NavigationBar var v = contentView.superview
while nil != v {
if let navigationBar = v as? NavigationBar {
return navigationBar
}
v = v?.superview
}
return nil
} }
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment