uinavigationbar

UINavigationBar setBackgroundImage in AppDelegate with Swift

无人久伴 提交于 2020-01-03 19:37:52
问题 I am trying to set a background image to the navigation bar globally in the App Delegate in Swift. I can get it to work on an individual View Controller like this: var topBar: UINavigationBar! topBar.setBackgroundImage(UIImage(named: "navbar"), forBarMetrics: .Default) But when I try and add the following to the App Delegate, it crashes with an uncaught exception: UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navbar"), forBarMetrics: .Default) 回答1: OK, I deleted the

How to set backButton text to empty?

孤街浪徒 提交于 2020-01-03 16:53:05
问题 I tried this code: navigationController?.navigationItem.backBarButtonItem?.title = "" but it does not work and did not change anything. How can I set backButton text to empty? 回答1: I tried this code for back button title. and it's work correctly let barButton = UIBarButtonItem() barButton.title = "" self.navigationController?.navigationBar.topItem?.backBarButtonItem = barButton 回答2: self.navigationController!.navigationBar.topItem!.title = "" 回答3: You should use: navigationItem

How do I turn off large titles for UINavigationBar?

安稳与你 提交于 2020-01-03 06:48:14
问题 I have a UITableView and a Detail View embedded in a UINavigationController as so: I would like to turn on large titles for "My Notes" but I'd like to turn it off for the detail view. Something like how the default Mail app works on iPhone. How would I change the navigation bar's prefersLargeTitle property during that segue? 回答1: it's very simple. In your DetailView you should set navigationItem.largeTitleDisplayMode to .never (not navigationController?.navigationItem.largeTitleDisplayMode !!

UISearchBar displaysSearchBarInNavigationBar

自闭症网瘾萝莉.ら 提交于 2020-01-03 05:07:13
问题 I want to replicate the functionality of the Twitter app where the search bar slides in to the navigation bar. However i have run into a problem. If i don't add [self.searchDisplayController setDisplaysSearchBarInNavigationBar:YES]; into viewDidLoad the bar will not appear. I have a search button in the righthand navigation item when i click it i call the above method. Is there anything i can do to ensure the search bar gets drawn Thanks Jonathan 回答1: You can add search bar on navigation bar.

TabBarController in NavigationController does not show TabBar in viewControllers

微笑、不失礼 提交于 2020-01-03 02:54:11
问题 I have a UITabBarController to whose controllers I would like to attach navigation. So I inserted the NavigationController as the entry controller, and the tabBarController as its root. All seems working fine, but for the tabBar. Basically it does not show, albeit the StoryBoard I attach seems to say differently. I also attach the Account Screen not showing any navigation bar nor, of course, any back button. Thanks, Fabrizio 回答1: Just a quick answer. I think you should put

Set NavigationBar Tint Color in iOS 7

大兔子大兔子 提交于 2020-01-03 02:31:12
问题 Am trying to set the tint for all navigation bars from my appdelegate in iOS 7. This worked always before, but for some reason now, nothing is changing. In the didFinishLaunching part of my appDelegate I have: [[UINavigationBar appearance] setTintColor:toolbarcolor]; However, the bar stays the default translucent option. 回答1: You can set the bar tint color using the barTintColor property: [[UINavigationBar appearance] setBarTintColor:[UIColor purpleColor]]; If you also don't want the

How can I make the text of a UIBarButtonItem wrap to two lines?

为君一笑 提交于 2020-01-03 00:52:28
问题 Some of the titles of view controllers in my UINavigationController are quite long, which makes the back button in the navigation bar of the next view controller in the hierarchy miss out some of the text, with a "..." instead. How could I make the text of the back button wrap onto two lines, as with "Now Playing" in the navigation bar of iPod.app? Thanks! 回答1: You could use the UIBarButtonItem method initWithCustomView: then set the rightBarButtonItem property in UINavigatiobItem. 来源: https:

UISearchBar in UINavigationBar can't add UIBarButtonItem

青春壹個敷衍的年華 提交于 2020-01-02 16:53:39
问题 I'm trying to add a UISearchBar to a UINavigationbar using self.searchDisplayController.displaysSearchBarInNavigationBar = YES; The UISearchBar gets added quite well into the UINavigationBar, but the left/right UIBarButtons are gone. I just can't figure out how to add them. Andy ideas or examples on this? 回答1: Dumb error from mine. When using self.searchDisplayController.displaysSearchBarInNavigationBar = YES; You need to use self.searchDisplayController.navigationItem to add the UIBarButtons

Navigationbar title alignment issue

自闭症网瘾萝莉.ら 提交于 2020-01-02 15:03:11
问题 I have set custom view as navigation bar titleView, when page is first view controller title is shown correctly in center but when view controller is pushed from another view controller title is shifted to right Code : -(void)setUpTwoLineNavigationTitle { CGFloat width = 0.95 * self.view.frame.size.width; UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, 44)]; contentView.backgroundColor = [UIColor clearColor]; CGRect titleRect = contentView.frame; titleRect.origin.y

Android 4.0: setting SYSTEM_UI_FLAG_LOW_PROFILE & SYSTEM_UI_FLAG_HIDE_NAVIGATION from Activity instead of View

时光总嘲笑我的痴心妄想 提交于 2020-01-02 10:29:14
问题 I am playing around with controlling the UI Navigation buttons in ICS. The current mechanism for suppressing the Nav Buttons is to call setSystemUiVisibility from a View using the SYSTEM_UI_FLAG_HIDE_NAVIGATION or SYSTEM_UI_FLAG_LOW_PROFILE flags. This seems like a strange place for setting these flags, as most other related settings (such as hiding the status bar) have been done through window LayoutParams properties. My question is if any of you have ideas for a good way to do it from an