Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save degt/fd5795e3732d423571ff to your computer and use it in GitHub Desktop.
Save degt/fd5795e3732d423571ff to your computer and use it in GitHub Desktop.
Change height of UINavigationBar
import Foundation
private var AssociatedObjectHandle: UInt8 = 0
extension UINavigationBar {
var height: CGFloat {
get {
if let h = objc_getAssociatedObject(self, &AssociatedObjectHandle) as? CGFloat {
return h
}
return 0
}
set {
objc_setAssociatedObject(self, &AssociatedObjectHandle, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
override public func sizeThatFits(size: CGSize) -> CGSize {
if self.height > 0 {
return CGSizeMake(self.superview!.bounds.size.width, self.height);
}
return super.sizeThatFits(size)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment