Swift 3 - How do I create a prominent button on a

2019-03-16 18:59发布

This question already has an answer here:

I am using Swift 3, Xcode 8.2.

I want to something like this (ignore the Oscars-themed fill) where the camera button is a bit more prominent/encircled on the tab bar:

enter image description here

I assume the whole thing is an image but is that image just naturally raised off the tab bar in some way?

Any resources or if you can point me in the right direction would be great. Thank you!

EDIT

I may have found another article that explains what I want to do: How do we create a bigger center UITabBar Item

2条回答
劳资没心,怎么记你
2楼-- · 2019-03-16 19:19

One solution would be to create your own subclass of the TabBar or just create a generic UIView that has the same properties as a TabBar (e.g. array of buttons that get displayed inside the view at certain heights, with the center one with a different height or offset value).

Another route you could take is to search and find other frameworks that are out there to use that do the same sort of functionality. A quick search on cocoacontrols came up with a couple options, the one that looked closest to what you are looking for is the RaisedCenterTabBar.

查看更多
Viruses.
3楼-- · 2019-03-16 19:20

One way is to simply add your UIButton on top of UITabBarController with the dummy center view controller.

Here I use storyboard and subclass UITabBarController to add that button:

enter image description here

This is my storyboard, note how the center view controller is just there for space:

enter image description here

With only those code and storyboard, this is the result:

enter image description here

Project here: https://github.com/aunnnn/TestButtonOnTabBar/

查看更多
登录 后发表回答