I am trying to add a custom control as the titleView in a UINavigationBar. When I do so, despite setting the frame and the properties that would normally assume full width,
Swift version of ksm's answer
let leftOffset: CGFloat = 60
let rightOffset: CGFloat = 60
@objc override var frame: CGRect {
didSet {
let width: CGFloat = UIScreen.main.bounds.width - leftOffset - rightOffset
let height: CGFloat = 44
super.frame = CGRect(
x: leftOffset,
y: 20,
width: width,
height: height
)
}
}