I have an iOS view with autolayout enabled and have a UIToolbar with a UISearchBar and UISegmentControl contained with the toolbar. I
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.