uinavigationbar

Add image to a navigationItem's title

夙愿已清 提交于 2019-12-04 18:43:33
问题 I'd like to add a logo to the left of my title on my navigation bar. The title property seems to only take an NSString. What's the best way to add an image to the navigation bar? 回答1: You can replace the title view with an image like this: navigationItem.titleView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"title_bar.png"]]; 回答2: Set UINavigationItem.titleView to a custom view (or just a straight UIImageView). 回答3: You can customize navigationItem.titleView , class of UIView

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 *

Set titleview for all navigationcontroller and navigationitem

落花浮王杯 提交于 2019-12-04 18:07:36
[[[UINavigationBar appearance] setTitleView:button] I tried to set title view as button for all navigation item using above line of code but it is not working.How can I set title view for all navigation bars in my project by writing small code in appdelegate ? Rajneesh071 Customizing the Appearance of a Navigation Bar it is alright to modify the barStyle, tintColor, and translucent properties, but you must never directly change UIView-level properties such as the frame, bounds, alpha, or hidden properties directly. For more detail you can follow apple doc UINavigationBar Class Reference Edit -

custom right bar button item in ios6 is not transparent

这一生的挚爱 提交于 2019-12-04 17:49:49
i am creating a custom right bar button item for my navbar using the following code : // create a toolbar UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 50, 44.01)]; // create the array to hold the button, which then gets added to the toolbar NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:1]; // create a toolbar item with image NSString* pathToSettingsResourceFile = [[NSBundle mainBundle] pathForResource:@"19-gear" ofType:@"png"]; UIImage* settingsImage = [[[UIImage alloc] initWithContentsOfFile:pathToSettingsResourceFile] autorelease]; settings = [

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

Add navigation bar on a view controller

自闭症网瘾萝莉.ら 提交于 2019-12-04 15:11:30
问题 i am new on iOS and i wanna add a navigation bar on my view controller with 2 buttons back on left and subscribe on right. ive got no clue how to do it..till now i have just added a nav bar from interface builder, created a (strong)refrnce for it in .h file and did following coding. navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, 1026, 50)]; [navBar setTintColor:[UIColor clearColor]]; [navBar setBackgroundColor:[UIColor redColor]]; [navBar setDelegate:self]; [self.view

iPhone iOS how to redraw UINavigationBar on demand?

久未见 提交于 2019-12-04 14:38:19
问题 I have code that changes the color of navigation bar using appearance attribute. I would like the change to the navbar color to be visible immediately. However, I cannot find a proper call to make to redraw the navbar. Currently it's color changes when I push a modal navigation controller, thus covering the navbar. This does not work: AppDelegate* appDelegate = ((AppDelegate*)[[UIApplication sharedApplication] delegate]); [appDelegate.window setNeedsDisplay]; I also tried asking various

Adding buttons to the titleview of NavigationBar without having to repeat code

主宰稳场 提交于 2019-12-04 13:29:38
To give some background, I am making a UINavigationControlled-based blog type app (I suppose it most closely resembles the iPhone facebook app). Regardless of the view that is currently active, the NavigationBar shows some buttons in its title area, such as Friend Requests and Activity Notifications. In much the same was as the facebook app, clicking these buttons will create a popup view. Currently, I am doing things in a way that I feel is incredibly inefficient. For every view that is loaded, I am recreating the buttons and adding them to the navigation bar. My code is below: //Setup the

UINavigationBar with solid color iOS 5

安稳与你 提交于 2019-12-04 13:20:06
I'm using the category to customize nav bar. My code is: - (void) drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColor(context, CGColorGetComponents([self.tintColor CGColor])); CGContextFillRect(context, rect); } It works well, but not in iOS 5. I need nav bar color to be solid without any gradient. How should I do this? As I know, for iOS 5 the only way to replace drawRect method is to make a subclass, but is there any way to make all navigation controllers to use UINavigationBar subclass instead of original class? In iOS 5 you can use the

iOS 7: Custom container view controller with UINavigationController as a child view controller

倾然丶 夕夏残阳落幕 提交于 2019-12-04 12:50:00
I would like to write a custom full-screen container view controller with the intention of putting a UINavigationController in it as a child view controller. The view of the UINavigationController will fill up the view of the container view controller so that it looks like the UINavigationController is the root view controller. (One would want to do something like this to, say, create the sliding sidebar menu UI popularized by Facebook.) What I've done works EXCEPT there is a glitch when presenting another view controller that hides the status bar when the iPhone is in landscape orientation.