Adding UIToolbar with two UIBarButtonItem to a UINavigationBar: poor UIToolbar and what about iPhone 4

后端 未结 4 1381
野性不改
野性不改 2021-02-04 16:54

I\'m following the second tip from here. In this tip two UIBarButtonItems are put together in a UIToolbar. Finally, the UIToolbar is added to the UINavigationBar. Now to my prob

相关标签:
4条回答
  • 2021-02-04 17:27

    An UIToolbar is designed to be used at the bottom of Iphone screen, so if you use somewhere else it will try to make an edge effect on top side. To avoid this the toolbar height should be 2 pixels bigger then Navbar height. Bu this time you will have a different side effect which causes an edge clear on the bottom side of the navbar. (The navbar in any case locates the rightbarbuttonitem as aligned in the middle)

    0 讨论(0)
  • 2021-02-04 17:32

    1) I can't explain the white line. Curious that it's only above your buttons. How are the buttons created? Also, is there a reason you're setting the height to 44.01, rather than just 44? I'm not positive that the height you set is honored in any case, they may be forced to 44 (someone correct me if I'm wrong).

    2) You don't have to do anything for iPhone 4, everything is scaled automatically.

    0 讨论(0)
  • 2021-02-04 17:33

    There's no guarantee that UIToolbar draws seamlessly inside a UINavigationBar; this might be responsible for the white line you're seeing.

    You might be able to subclass UIToolbar so that it doesn't draw (i.e. override -drawRect: to not do anything).

    0 讨论(0)
  • 2021-02-04 17:39

    Did you try adding those buttons not inside a container UIView and then adding it as an item but manipulating with UIBarButtonSystemItemFlexibleSpace? I mean adding each of those buttons as an independent item.

    0 讨论(0)
提交回复
热议问题