uinavigationitem

How do I vertically correct the navigationBar's titleView text position when using a custom font?

坚强是说给别人听的谎言 提交于 2019-12-04 18:25:57
问题 We're using custom fonts for the titleView in the navigation bar. Somehow Apple always draws this font too high. How do I correct for this strange offset you get when you are using custom fonts in a navbar? 回答1: I used setTitleVerticalPositionAdjustment:forBarMetrics: . Compatibility: available starting from iOS 5. 回答2: Your can set a new view as titleView , then add a new label to it: UIView * customTitleView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 200.0f, 40.0f)]; UILabel *

How to hide/disable only the first uinavigationbar?

孤人 提交于 2019-12-04 17:47:42
问题 I've been wandering how to hide / remove / disable only the main or first navigation bar in the navigation controller so that I could put an image as a whole background screen but I couldn't find any solution. Did try hide the titleview in viewdidLoad of the main navigation controller but didn't work. Tried using navigationBarHidden but it hides the whole navigation bar for the next stack of controller. So, I'm not sure how to do this. To give you an example, I would like to have something

UISearchBar and UINavigationItem

故事扮演 提交于 2019-12-04 16:50:47
I can't seem to get a UISearchBar to position itself from the far left to the far right in the navigation bar. In the -(void)viewDidLoad method, I have the following code: UISearchBar *sb = [[UISearchBar alloc] initWithFrame:self.tableView.tableHeaderView.frame]; sb.delegate = self; self.navigationItem.titleView = sb; [sb sizeToFit]; [sb release]; When you build and run, it looks just fine at first glance. However, looking more closely, you can tell there is a margin/space on the left. This wouldn't be a big deal in the grand scheme of things, but when I tap the search bar to start a search, I

UINavigationItem titleView position

隐身守侯 提交于 2019-12-04 16:33:40
问题 I'm using UINavigationItem's titleView property to set a custom UILabel with my desired font size/color. Here's my code: self.headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 400.0, 44.0)]; self.headerLabel.textAlignment = UITextAlignmentCenter; self.headerLabel.backgroundColor = [UIColor clearColor]; self.headerLabel.font = [UIFont boldSystemFontOfSize:20.0]; self.headerLabel.textColor = [UIColor colorWithRed:0.259 green:0.280 blue:0.312 alpha:1.0]; self.navigationItem

UIButton style when added to navigationItem.titleView

為{幸葍}努か 提交于 2019-12-04 14:38:02
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"? You can use UISegmentedControl: UISegmentedControl *mySegmentedControl = [[UISegmentedControl alloc] initWithItems:@"Example"]];

UINavigationController back button problem in landscape mode?

感情迁移 提交于 2019-12-04 14:28:32
my iphone application supports portrait mode earlier, now i want to support land scape mode also. everything is working fine in my application except the navigation controller back button. i have used tableviews in navigaton conroller, when i click back button in landscape mode view is getting poped and its loading its previous view but animation is strange. i have given default animation but, in landscape mode view is is animating upside down instead of default left to rite when i click back button. does anyone faced this kind of problem??? thanks in advance. i understood the problem and

How to remove UINavigatonItem's border line

偶尔善良 提交于 2019-12-04 10:44:48
Is it possible to remove UINavigationItem's border? My view under black nav. bar is black and i don't want no visual border between them. To make it clearer (image is not from my app): You can't hide it. You can add a subview that will mask it. Example: UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 43, 320, 1)]; [overlayView setBackgroundColor:[UIColor whiteColor]]; [navBar addSubview:overlayView]; // navBar is your UINavigationBar instance [overlayView release]; I didn't check it, but it should work. EDIT: I checked it, it works. Nick in iOS6,you can hide it by set a

How do you determine the size/frame of a custom UINavigationItem.titleView?

旧街凉风 提交于 2019-12-04 07:47:17
After creating a custom view and assigning it to the navigationItem.titleView property it is displayed like this with the custom view filling the space between the two buttons. Therefore, the custom view is not centered on the navigation bar. How do I determine the frame of the view in the .titleView property? I want to center some text in the navigation bar, say under the time stamp. If you really want to get titleView 's frame (in your top-level view's coordinate space), you can do this: [self.navBar layoutIfNeeded]; CGRect titleViewFrameInTopLevelViewSpace = [self.navigationItem.titleView

IOS - Swift - adding target and action to BarButtonItem's customView

孤街浪徒 提交于 2019-12-04 07:07:03
I'm creating a custom view, with a uiimageview as a subview. I'm then using that custom view in my navigation bar as the rightBarButtonItem. This works to display the proper icon in the proper location, but for whatever reason the function I define in "action" is never being called, so the segue isn't performed when I tap on the rightBarButtonItem. Oddly enough if I do NOT insert a custom view, but instead comment that bit out and just set a title, target, and action for rightItem then the function is performed properly. somehow adding that custom view messes with the target and action

How to prevent Large Title from Collapsing

做~自己de王妃 提交于 2019-12-04 03:30:25
The question is simple, how can I prevent a Large Title Navigation Bar from collapse when a scrollview scrolls down? My navigation must have a large navigation bar at all times... so when a scrollview scroll, the navigation bar shouldn't collapse up, it should stay the same size, how can I do that? This is how I set the largeTitle preferences override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.navigationItem.hidesBackButton = true presenter.expandForSimulatorLayoutIfNeeded() } func expandForSimulatorLayoutIfNeeded(){ if !isExpanded{ topMenu = TopMenu(frame: