Answer the question
In order to leave comments, you need to log in
How to place UISegmentedControl in UINavigationBar?
Good day. I really need help.
Faced the following problem:
you need to place a UISegmentedControl in a UINavigationBar as in the picture
. I have already tried several options:
1. placed the segmented control in the title of the navigation bar, and the title itself was indicated in the prompt. The result is not the same.
2. I was told that in the picture this is not a standard UINavigationBar, but a UIView.
At this stage, I'm trying to implement using the 2nd option, but I already see that there will be a lot of problems.
Perhaps someone faced such a problem? Perhaps there is a ready solution?
I will be very grateful for advice.
Answer the question
In order to leave comments, you need to log in
An example of what happened .
Example
You need to configure a little more, but the essence is clear.
1. Create a CustomNavigationBar class: UINavigationBar .
2. Initialize UInavigationController using your CustomNavigationBar . [[UInavigationController alloc] initWithNavigationBarClass:[CustomNavigationBar class] toolbarClass:nil];
3. Well, then, CustomNavigationBar is at your complete disposal. Add at least UISegmentedControl to it , at least your own implementation of such functionality.
stackoverflow.com/questions/6672229/how-to-subclas...
may help
stackoverflow.com/questions/15587978/uisegmentedco...
stackoverflow.com/questions/18813563/add-segmented...
I think this is really not a navigation bar, it’s not clear what height it has here
All the same, I managed to achieve the desired result in the following way:
1. Under the navigation bar, I placed a uiview with a segmented control
2. Removed the bottom border from the navigation bar
3. Added a bottom border from the UIView 4.
Plus
manipulations with constraints for the view controller
I can give a link to github
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question