Why should I use a UIToolbar vs using a UIView?
Asked Answered
K

2

6

I'm building an instant messenger app in iOS. In particular I'm implementing the UI for a conversation in the most typical way, that is placing an input bar at the bottom of the view (UICollectionView to be clear) that scrolls above the keyboard. Now, I'm wondering if I should implement this view as a UIToolbar with UIBarButtonItems instead of a custom UIView with UIButtons. What are the advantages of a UIToolbar?

Kendallkendell answered 17/11, 2015 at 15:34 Comment(0)
U
7

I don't think there is much difference other than convenience. With a UIToolbar you get the following:

  • UIBarButton items are arguably simpler to add to a tool bar and the layout is automatic, whereas it is a bit more complicated adding buttons to a view.

  • You can set hidesBottomBarWhenPushed on the view controllers to
    hide the bar when a view controller is pushed to the nav stack.

  • Looks more familiar to other apps, including Apple's own apps.

If you use a UIView with buttons you have more flexibility in the appearance but you have to do a bit more work, but other than that I can't really see much difference.

Uraninite answered 17/11, 2015 at 15:47 Comment(0)
H
3

UIToolbar will provide automatic placing of your buttons, saving you from pain of placing those buttons. It was designed specifically for this reason.

Have answered 17/11, 2015 at 15:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.