UIButton in Navigation Bar Not Recognizing Taps in iOS 11

前端 未结 3 1368
心在旅途
心在旅途 2020-12-18 01:09

I have a UIButton in a navigation bar that sits over the top of a UIImage and a UILabel. It worked fine in iOS 10, but now in iOS 11 i

3条回答
  •  抹茶落季
    2020-12-18 01:45

    Adding to Clifton Labrum, this is the way to go. Apple changed the way navigation bars work in iOS 11. This can also be done in Storyboard but through descendant constraints.

    The Custom view inside UIBarButtonItem can NOT be given constraints directly. Instead, provide its subviews with constraints, and the Custom view will get its constraints implicitly:

    The custom view will implicitly get its size because of those constraints.

    This should fix all the weird behavior caused by iOS 11.

提交回复
热议问题