uinavigationbar

vertically aligning UINavigationItems

China☆狼群 提交于 2019-11-26 20:59:42
问题 I have customized the UINavigationBar's height to 100px and I'd like to add buttons onto this customized bar. All is good except the button seems to want to sit on the bottom of the nav bar no matter what. I can't get it to align to the center or the top of the nav bar. Here is the code; first I create a navigation controller in the app delegate and add one button on the right. // set main navigation controller temp *tempc = [[temp alloc] initWithNibName:@"temp" bundle:nil]; self

UIBarButtonItem Custom view in UINavigationBar

戏子无情 提交于 2019-11-26 20:54:02
问题 I am making a custom bar buttons for uinavigationbar, I am using following code UIImageView *backImgView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chk_back.png"]]; [backImgView setUserInteractionEnabled:YES]; UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:backImgView]; [backButton setTarget:self]; [backButton setAction:@selector(BackBtn)]; checkIn_NavBar.topItem.leftBarButtonItem = backButton; The problem is it is not calling its action. What i am

iOS UINavigationBar button remains faded after segue back

三世轮回 提交于 2019-11-26 20:48:59
In my app I have multiple view controllers, and most have a right-hand-side UIBarButtonItem with direct "show" segue actions attached. Having segued to another view and then pressed the '< Back' button, the original button item remains faded out, although still otherwise usable. This only appears to happen under iOS 11.2. I can't see any setting that could be doing this, and in at least one of the cases where this happens there's no specific segue unwinding nor viewDidAppear handling. I'd post some code, but AFAICS it's all just default UINavigationBar behaviour. This is a bug in iOS 11.2 and

Changing the height of the Navigation bar iOS Swift

依然范特西╮ 提交于 2019-11-26 20:47:49
I am trying to change the height of there navigation bar for my app. Currently the height is fixed to 44. I can change the width from Xcode but not the height. I have no idea how to change this. Very new to iOS development. Can anyone please help? iAnurag Try this : import UIKit class YourViewController : UIViewController { var navBar: UINavigationBar = UINavigationBar() override func viewDidLoad() { super.viewDidLoad() self.setNavBarToTheView() // Do any additional setup after loading the view. self.title = "test test" } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning(

How to resize Title in a navigation bar dynamically

余生长醉 提交于 2019-11-26 20:10:39
问题 I have some views that show up in a navigation controller. Two of these views have a longer title for the navigation bar. The problem is that when the title is too long to fit, some characters are truncated and "..." is added. Is there any way I can tell the Navigation bar to re-size the title text automatically to fit? 回答1: Used the below code in ViewDidload . Objective C self.title = @"Your TiTle Text"; UILabel* tlabel=[[UILabel alloc] initWithFrame:CGRectMake(0,0, 200, 40)]; tlabel.text

UISearchBar in navigationbar

廉价感情. 提交于 2019-11-26 19:50:58
How can I show a UISearchBar in the NavigationBar? I can't figure out how to do this. Your help is very much appreciated. To put searchBar into the center of navigationBar: self.navigationItem.titleView = self.searchBarTop; To put searchBar to the left/right side of navigationBar: UIBarButtonItem *searchBarItem = [[UIBarButtonItem alloc] initWithCustomView:searchBar]; self.navigationItem.rightBarButtonItem = searchBarItem; As of iOS 7, the UISearchDisplayController supports this by default. Set the UISearchDisplayController's displaysSearchBarInNavigationBar = YES to get this working easily.

How to add background image on iphone Navigation bar?

一曲冷凌霜 提交于 2019-11-26 19:37:16
I want to add an image background to my navigation bar. Is it right? //set custom background image UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NavigationBackground.png"]]; [self.navigationBar insertSubview:backgroundView atIndex:0]; [backgroundView release]; Here's the code from the link @luvieere mentioned. Paste this code into to the rootview controller just above @implementation rootviewController @implementation UINavigationBar (CustomImage) - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed:@"NavigationBar.png"]; [image

Change position of UIBarButtonItem in UINavigationBar

你。 提交于 2019-11-26 19:28:44
How can I change the position of a UIBarButtonItem in a UINavigationBar? I would like my button to be about 5px higher than its normal position. There is no particularly good way to do this. Your best bet if you really must is to subclass UINavigationBar, and override layoutSubviews to call [super layoutSubviews] and then find and reposition the button's view. This code creates a back button for UINavigationBar with image background and custom position. The trick is to create an intermediate view and modify its bounds. UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage

Change font of back navigation bar button

一曲冷凌霜 提交于 2019-11-26 19:21:44
问题 I want to be able to set the font of my apps navigation bar back button without doing anything too crazy and without losing any other design characteristics of the button (i.e. I want to keep the arrow). Right now I use this in viewDidAppear: to set the font of the normal bar button items. for (NSObject *view in self.navigationController.navigationBar.subviews) { if ([view isKindOfClass:[UIButton class]]) { [((UIButton*)view).titleLabel setFont:[UIFont fontWithName:@"Gill Sans" size:14.0]]; }

Changing navigation bar color in Swift

你说的曾经没有我的故事 提交于 2019-11-26 19:18:54
I am using a Picker View to allow the user to choose the colour theme for the entire app. I am planning on changing the colour of the navigation bar, background and possibly the tab bar (if that is possible). I've been researching how to do this but can't find any Swift examples. Could anyone please give me an example of the code I would need to use to change the navigation bar colour and navigation bar text colour? (The Picker View is set up, I'm just looking for the code to change the UI colours) Thanks. trumpeter201 Navigation Bar: navigationController?.navigationBar.barTintColor = UIColor