uinavigationbar

Transparent UINavigationBar in Swift

此生再无相见时 提交于 2019-11-27 10:32:58
问题 I am trying to make my UINavigationBar in UINavigationController transparent. I created a subclass of UINavigationController and liked it to a scene in my storyboard file. Here's a piece of my subclass: override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. let size = self.navigationBar.frame.size self.navigationBar.setBackgroundImage(imageWithColor(UIColor.blackColor(), size: size, alpha: 0.2), forBarMetrics: UIBarMetrics.Default) } override func

How to add a button to UINavigationBar?

雨燕双飞 提交于 2019-11-27 10:26:42
How to add a button to UINavigationBar programmatically? Mads Mobæk Sample code to set the rightbutton on a NavigationBar . UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:nil action:nil]; UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@"Title"]; item.rightBarButtonItem = rightButton; item.hidesBackButton = YES; [bar pushNavigationItem:item animated:NO]; But normally you would have a NavigationController , enabling you to write: UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"

How to set the title of a Navigation Bar programmatically?

不想你离开。 提交于 2019-11-27 10:25:53
问题 I have a Navigation Bar in a view, and I want to change its Navigation Item title programmatically. How is this done? 回答1: In your UIViewController self.navigationItem.title = @"The title"; 回答2: Swift 3 Version: If you use a navigation bar without navigation controller, then you can try this: navigationBar.topItem?.title = "Your Title" Hope for help. 回答3: In viewDidLoad self.title = @"Title"; 回答4: From Apple Documentation: The most common way to use a navigation bar is with a navigation

Multiple UIBarButtonItems in UINavigationBar

折月煮酒 提交于 2019-11-27 09:52:36
问题 How to Create multiple bar button in navigation bar? 回答1: You must use UIToolbar and set the toolbar with buttons: // create a toolbar where we can place some buttons UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 45)]; [toolbar setBarStyle: UIBarStyleBlackOpaque]; // create an array for the buttons NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:3]; // create a standard save button UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]

Increase NavigationBar height

吃可爱长大的小学妹 提交于 2019-11-27 09:36:12
I have the following code: func navbarbutton() { UIView.animateWithDuration(0.2, animations: { () -> Void in let current = self.navigationController?.navigationBar.frame self.navigationController?.navigationBar.frame = CGRectMake(self.frame!.origin.x, self.frame!.origin.y, self.frame!.size.width, current!.size.height + 50) self.navigationController?.navigationBar.layoutIfNeeded() }) } I'm able to increase the height of the navigation bar by 50 dp. That's not the issue for me. The issue I'm having is that the UIBarButtonItems are all aligned to the bottom. How can I get them aligned to the top

Use the increased navigation-bar title in iOS 11

北战南征 提交于 2019-11-27 09:28:22
问题 iOS 11 Beta 1 uses the increased navigation-bar title for almost all system-apps (it started doing this in iOS 10 and the Music app). I am wondering if Apple has a public API for this coming in iOS 11, or whether it will stay private for now. The behavior is that the title has an increased font-size, is left aligned and will move to the navigation-bar once the user scrolls down. I've attached some screens showing this behavior in the Messages app here: Although I could not find any reference

UINavigationBar/Status Bar issue in IOS7

北慕城南 提交于 2019-11-27 09:22:07
问题 Final EDIT (Rather than having an overly long question with edits making a final edit for clarification, please see other edits if needed). Controller Setup I have an application that is setup as follows: InitialViewController (subclass of ECSlidingViewController) Main Navigation Controller (subclass of UINavigationController ) Main Home View Controller (subclass of UIViewController ) In the viewDidLoad of the initialViewController I load the main navigation controller in with the Home View

iOS 11 SearchBar in NavigationBar

Deadly 提交于 2019-11-27 09:13:29
问题 With iOS 11 Apple has redesigned the UISearchBar by making the corners rounder and the height bigger. Adding a UISearchBar to the navigationBar is pretty simple by just setting it as the titleView of the navigationItem using navigationItem.titleView = searchBar . However, in iOS 11 it does not seem to work anymore as expected. Have a look at the screens where we compare the same setup using iOS 10 and iOS 11 iOS 10 iOS 11 You can clearly see that the SearchBar increases the size of the

Navigation bar is moving up to statusbar

依然范特西╮ 提交于 2019-11-27 08:34:14
问题 I have a viewController . Which does not have navigationBar. I am pushing another viewController that has navigationBar. Which is going up I am using following code to show the navigationBar self.navigationController?.setNavigationBarHidden(false, animated: false) 回答1: I believe you trying to hide navigationBar in firstVC and show it in secondVC . Try following method into your firstVC and make sure you embedded your firstVC with navigationController . Your storyBoard flow layout should be

iOS开发UINavigation系列一——导航栏UINavigtionBar

末鹿安然 提交于 2019-11-27 08:14:54
iOS开发UINavigation系列一——导航栏UINavigtionBar 一、导航栏的使用 在iOS开发中,我们通常会使用导航控制器,导航控制器中封装了一个UINavigationBar,实际上,我们也可以在不使用导航控制器的前提下,单独使用导航栏,在UINavigationBar中,也有许多我们可以定制的属性,用起来十分方便。 二、UINavigationBar的创建和风格类型 导航栏继承于UIView,所以我们可以像创建普通视图那样创建导航栏,比如我们创建一个高度为80的导航栏,将其放在ViewController的头部,代码如下: UINavigationBar *bar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 80)]; [self.view addSubview:bar]; 效果如下: 我们也可以设置导航栏的风格属性,从iOS6之后,UINavigationBar默认为半透明的样式,从上面也可以看出,白色的导航栏下面透出些许背景的红色。导航栏的风格属性可以通过下面的属性来设置: @property(nonatomic,assign) UIBarStyle barStyle; UIBarStyle是一个枚举,其中大部分的样式都已弃用,有效果的只有如下两个: typedef NS