iOS Autolayout and UIToolbar/UIBarButtonItems

前端 未结 3 2084
南旧
南旧 2020-12-03 10:07

I have an iOS view with autolayout enabled and have a UIToolbar with a UISearchBar and UISegmentControl contained with the toolbar. I

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 10:54

    Autolayout constraints only work with UIViews and their subclasses.

    While UIToolbar allows some UIView based items (such as UISearchBar and UISegmentedControl) they may have to coexist with UIBarButtonItems which do not inherit from UIView.

    Until autolayout can work with UIBarButtonItems, do as you have done.

    Your alternative is to roll your own toolbar with widgets based only on UIViews.

提交回复
热议问题