Can't set titleView in the center of navigation bar because back button

前端 未结 10 1541
情话喂你
情话喂你 2020-12-08 02:25

I\'m using an image view to display an image in my nav bar. The problem is that I can\'t set it to the center correctly because of the back button. I checked the related que

10条回答
  •  时光取名叫无心
    2020-12-08 02:48

    Qun Li's worked perfectly for me. Here's the swift 2.3 code:

    override var frame: CGRect {
        set(newValue) {
            super.frame = newValue
    
            if let superview = self.superview {
                self.center = CGPoint(x: superview.center.x, y: self.center.y)
            }
        }
    
        get {
            return super.frame
        }
    }
    

提交回复
热议问题