uinavigationitem

Padding wrong when presenting second modal navigation controller on iOS 13

自闭症网瘾萝莉.ら 提交于 2020-01-25 06:49:14
问题 On iOS 13, when presenting a second modal view controller over a first one, the padding is incorrect on the button bar items. In particular, the right margin disappears. How should this be fixed? 回答1: This behavior is due to a bug in iOS 13. It can be fixed by calling setNeedsLayout on the Navigation Bar. Swift example: override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if #available(iOS 13.0, *) { navigationController?.navigationBar.setNeedsLayout() } } Objective

use [UINavigationBar appearance] to change back button image

折月煮酒 提交于 2020-01-23 11:52:04
问题 I'd like to change the back button of my UINavigationBar I can do it using this code: // Set the custom back button UIImage *buttonImage = [UIImage imageNamed:@"backag.png"]; //create the button and assign the image UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:buttonImage forState:UIControlStateNormal]; [button setImage:[UIImage imageNamed:@"selback.png"] forState:UIControlStateHighlighted]; button.adjustsImageWhenDisabled = NO; //set the frame of the

UIButton style when added to navigationItem.titleView

喜欢而已 提交于 2020-01-23 02:03:33
问题 I need to add a button to the UINavigationItem titleView (actually to the center of the UINavigation Bar. I've used the following code to accomplish so: UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(0, 0, 70, 30); [btn setSelected:YES]; [btn setTitle:@"list" forState:UIControlStateNormal]; And I've go the following: I need to give the same style of the "Done" button (which is UIBarButtonItem ) to the button "list"? 回答1: You can use

Multiple Modally Presented (page sheet) ViewControllers Navigation Item Bug

不羁岁月 提交于 2020-01-17 14:04:06
问题 iOS 13. The problem is shown on the screenshot. The steps are: Open one view controller modally with page sheet style. Open another (second) view controller modally with page sheet style. Expected: no Nav Bar bug Actual: see screenshot The source code is available here: https://github.com/rinat-enikeev/NavBarBug Question: how to fix this bug? I want to present 2 view controllers modally with page sheet style. 回答1: Ok, for those who faced the same issue. The workaround is to add the following

move navigationBar's left and right barButtonItem's vertically upwards

放肆的年华 提交于 2020-01-17 07:25:52
问题 I am trying to move my navigation bar's left and right barButtonItem's upwards vertically without any success. I can manage to move the title view up but using the same method for the barButtonItem's doesn't do anything. The effect I'm trying to achieve is what is used on the Bookmarks page of safari: I'm hoping to achieve this without any subclassing of the navigationBar so that I can maintain the translucency. My approach was to add UIView's to the navigationBar directly in IB for the

UISegmentedControl, UIToolbar and UINavigationItem

二次信任 提交于 2020-01-12 13:41:46
问题 I've create a UISegmentedControl and successfully attached it to my navigationItem.tableView. But when I try instead to attach it to a UIToolbar, it blows up. I'm sure I've seen UISegementedControls on toolbars before - but can't seem to get it working. Thoughts? // works NSArray *statusItems = [[NSArray alloc] initWithObjects:@"one", @"two", nil]; statusSegments_ = [[UISegmentedControl alloc] initWithItems:statusItems]; self.navigationItem.titleView = statusSegments_; // doesn't work NSArray

Navigation bar titleView alignment

假如想象 提交于 2020-01-12 08:08:52
问题 I want my navigation bar to show two things in the middle. One them is going to be List name, and the other one will be name of users. User names will be placed under list name. What i have done so far is, i created two label and one superview programatically and set the titleView of navigationItem . override func viewDidLoad() { super.viewDidLoad() var rectForView = CGRect(x: 0, y: 0, width: 190, height: 176) var viewForTitle = UIView(frame: rectForView) var rectForNameLabel = CGRect(x: 0, y

Navigation bar titleView alignment

故事扮演 提交于 2020-01-12 08:08:51
问题 I want my navigation bar to show two things in the middle. One them is going to be List name, and the other one will be name of users. User names will be placed under list name. What i have done so far is, i created two label and one superview programatically and set the titleView of navigationItem . override func viewDidLoad() { super.viewDidLoad() var rectForView = CGRect(x: 0, y: 0, width: 190, height: 176) var viewForTitle = UIView(frame: rectForView) var rectForNameLabel = CGRect(x: 0, y

Adding Navigation Item in UIViewController

时光怂恿深爱的人放手 提交于 2020-01-06 19:05:12
问题 I'm trying to add UINavigationItem to my UIViewController as mentioned this answer. However the Navigation bar is not showing in my view. I tried even adding an outlet and setting the title programmatically and also adding the NavigationItem in two different places. Still it doesn't show. This view controller is embedded in a TabBarController. WHat am I missing here? Thanks is advance. 回答1: This view controller is embedded in a TabBarController But is it embedded, first and foremost, in a

Xcode 10 NavigationBar icons not appearing on some devices

本秂侑毒 提交于 2020-01-05 07:08:10
问题 I am using Xcode 10 today, during development and testing I noticed that icons did not appear in iPhone 5s, iPhone 6s, iPhone 7s, just work on iPhone X, I set this icons by using xCode storyboard , I attached images to make my question more clear. Thanks. * please check the NavigationBar * iPhone 6s iPhone X 回答1: Unfortunately, this bug with xCode 10, sometimes icons not appears not only in Navigation in all the app views, but some people also said: "The fix was setting color profile to sRGB.