uinavigationitem

rightBarButtonItem info button, no space to the right

匆匆过客 提交于 2019-12-03 07:40:03
问题 I have a UIViewController set up to display an info-button on the right in its UINavigationItem like this: UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; [infoButton addTarget:self action:@selector(toggleAboutView) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:infoButton] autorelease]; That works perfectly, but the only problem is that I'm left with little to no space to the right

How do I get the width of the back button in a UINavigationBar?

Deadly 提交于 2019-12-03 04:06:36
We have a controller that might be pushed from several places, so its back button might have one of several titles. It also has a button that pops up another controller. They both have the same custom title element, but they're centred differently because the second controller has no back button. I'd like to add a spacer to fix this, but I don't know what width to make it. How do I get the width of the back button in a UINavigationBar? You could always spelunk through the navigation bar's subviews, looking for the back button view and picking off the size when you find it. I did a blog post a

iOS 11 - UINavigationItem titleView when using Large Titles mode

霸气de小男生 提交于 2019-12-03 03:24:33
I'm trying to understand either it's a bug or it's the expected behavior. On iOS 10 and earlier we could set up a custom title, using navigationItem.titleView . On iOS 11 , when setting our navigationItem.largeTitleDisplayMode = .always and setting navigationItem.titleView = <Some cool UIButton> it's displaying both the normal navigation title bar and the large navigation title. Illustration: To sum up: How can we use custom titleView on our Large Navigation Title? EDIT : This is the expected result: I was able to replace the navigation bar big title with a custom view by using a subclass of

Adjusting navigationItem.titleView's frame?

二次信任 提交于 2019-12-03 03:13:35
问题 I noticed that the titleView's position depends on the rightbarbutton title. How can I set the frame of the titleView to be in the center instead? I've tried setting titleView.frame, but to no avail. Here's the code: UIButton *titleLabel = [UIButton buttonWithType:UIButtonTypeCustom]; [titleLabel setTitle:@"Right Eye" forState:UIControlStateNormal]; [titleLabel setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [titleLabel setTitleColor:[UIColor blackColor] forState

rightBarButtonItem info button, no space to the right

旧城冷巷雨未停 提交于 2019-12-02 22:39:28
I have a UIViewController set up to display an info-button on the right in its UINavigationItem like this: UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; [infoButton addTarget:self action:@selector(toggleAboutView) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:infoButton] autorelease]; That works perfectly, but the only problem is that I'm left with little to no space to the right of the button, which looks pretty ugly: Is there any way for the button to move about 5 px out from the

navigation bar right bar button items spacing

浪子不回头ぞ 提交于 2019-12-02 18:07:36
I have created a with left bar button item added from storyboard, titleView and three right bar button items from code. Here is the code: override func viewDidLoad() { super.viewDidLoad() var screenWidth = UIScreen.mainScreen().bounds.width // custom title view var navBarWidth: CGFloat = self.navigationController!.navigationBar.frame.size.width let customTitleView = UIView(frame: CGRectMake(0, 0, navBarWidth, 44)) titleLabel = UILabel(frame: CGRectMake(20, 0, navBarWidth, 40)) titleLabel.text = conversationName if let titleFont = UIFont(name: "Roboto-Regular", size: 20) { titleLabel.font =

Adjusting navigationItem.titleView's frame?

假如想象 提交于 2019-12-02 16:38:57
I noticed that the titleView's position depends on the rightbarbutton title. How can I set the frame of the titleView to be in the center instead? I've tried setting titleView.frame, but to no avail. Here's the code: UIButton *titleLabel = [UIButton buttonWithType:UIButtonTypeCustom]; [titleLabel setTitle:@"Right Eye" forState:UIControlStateNormal]; [titleLabel setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [titleLabel setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted]; titleLabel.frame = CGRectMake(100, 0, 180, 44); titleLabel.titleLabel.backgroundColor

Setting title of UINavigationbar not working

孤街浪徒 提交于 2019-12-02 14:19:27
问题 I've looked through a few online tutorials, but nothing is working. That's the code of my viewController: import UIKit class ViewController: UINavigationController { let textView = UITextView() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. // tried this self.navigationItem.title = "AAA" // and this self.title = "AAA" // and finally this self.parent?.title = "AAA" } } I don't understand why this isn't working (I haven

Back button not made on navigation bar

﹥>﹥吖頭↗ 提交于 2019-12-02 12:39:58
问题 I started out with a navigation based project and am pushing further views onto the controller. The problem is that if I do not give a title to the navigation item then the back button is not drawn! Only if I give the navigation bar a title, will the back button come. It seems apple could'nt write "back" or "go back" in case of NO title. I do not want to give the navigation item a title(I'll use a label inside my view). So how do I fix this? - (void)viewDidLoad { [super viewDidLoad]; self

Setting title of UINavigationbar not working

懵懂的女人 提交于 2019-12-02 11:53:08
I've looked through a few online tutorials, but nothing is working. That's the code of my viewController: import UIKit class ViewController: UINavigationController { let textView = UITextView() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. // tried this self.navigationItem.title = "AAA" // and this self.title = "AAA" // and finally this self.parent?.title = "AAA" } } I don't understand why this isn't working (I haven't used a navigation bar before) I didn't change anything in the main.storyboard. Thanks for your