uinavigationbar

How do I change the background of a UINavigationBar?

偶尔善良 提交于 2019-12-17 18:47:20
问题 I'd like to change the background of my UINavigationBar to a [UIColor colorWithImage:] , but it isn't working. What am I missing? EDIT: Once I've created my subclass, where do I set the UINavigationController to use it? 回答1: You can use the tintColor property to change the colour of a UINavigationBar , but to set an image as the background you'll have to provide your own UINavigationBar subclass and override the drawRect: method, for example: - (void)drawRect:(CGRect)rect { // Drawing code

How to hide the navigation bar and toolbar as scroll down? Swift (like myBridge app)

爷,独闯天下 提交于 2019-12-17 17:26:52
问题 I want to hide a toolbar and nav bar as I scroll down a page. And return it as I scroll up. How is this possible? How would I go about detecting the drag? Do I use pan gesture or is this down with the scrollview? 回答1: Try this simple approach: Tested in Swift 3 func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { if(velocity.y>0) { //Code will work without the animation block.I am using animation block

How to set multi line Large title in navigation bar? ( New feature of iOS 11)

╄→гoц情女王★ 提交于 2019-12-17 15:39:33
问题 I am in process of adding large title in navigation bar in one of the application. The issue is title is little long so I will require to add two lines in large title. How can I add large title with two lines in navigation bar ? This is not about default navigation bar title ! This is about large title which is introduced in iOS 11 . So make sure you add suggestions by considering large title. Thanks 回答1: Based in @krunal answer, this is working for me: extension UIViewController { func

How do you add more than one UIBarButton on UINavigationItem.rightBarButtonItem (or leftBarButtonItem)?

徘徊边缘 提交于 2019-12-17 15:34:50
问题 I have tried this approach/hack: http://blog.blackwhale.at/2009/06/uibuttons-in-uinavigationbar/ The problem is this leaves a faint seam. I tried setting the background image of the nested toolbar to an image I captured of what it should be. That didn't work. The image was not applied. I have also tried using a nested UINavigationBar and that didn't seem to work. I have seen this done in several iPhone apps. Does anyone know how? [EDIT] I want the buttons to look like normal UIBarButtonItems

iOS 11 UISearchBar in UINavigationBar

和自甴很熟 提交于 2019-12-17 15:27:54
问题 I want to place a search bar in the new navigation bar with the new iOS 11 large titles. However, the color of the search bar is automatically applied by iOS and I can't change it. if #available(iOS 11.0, *) { let sc = UISearchController(searchResultsController: nil) navigationItem.searchController = sc navigationItem.hidesSearchBarWhenScrolling = false } The search bar get's a deep blue background, but I just want to change it to white. Setting the background color results in this:

presenting ViewController with NavigationViewController swift

旧街凉风 提交于 2019-12-17 15:19:58
问题 I have system "NavigationViewController -> MyViewController", and I programmatically want to present MyViewController inside a third view controller. The problem is that I don't have navigation bar in MyViewController after presenting it. Can you help me? var VC1 = self.storyboard.instantiateViewControllerWithIdentifier("MyViewController") as ViewController self.presentViewController(VC1, animated:true, completion: nil) 回答1: Calling presentViewController presents the view controller modally ,

NavigationBar bar, tint, and title text color in iOS 8

一笑奈何 提交于 2019-12-17 14:59:22
问题 The background text in the status bar is still black. How do I change the color to white? // io8, swift, Xcode 6.0.1 override func viewDidLoad() { super.viewDidLoad() self.navigationController?.navigationBar.barTintColor = UIColor.blackColor() self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orangeColor()] } 回答1: In AppDelegate.swift , in application(_:didFinishLaunchingWithOptions:) I put the following: UINavigationBar.appearance()

iOS7 when UIsearchbar added in UINavigationBar not showing cancel button

我只是一个虾纸丫 提交于 2019-12-17 10:44:52
问题 I add UISearchBar above UINavigationBar and set UIsearchbar showsCancelButton YES, work fine in iOS6 but in iOS7 not showing cancel button. I used below code snippet UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 600, 44)]; searchBar.showsCancelButton = YES; searchBar.translucent = NO; [searchBar setTintColor:[UIColor redColor]]; searchBar.backgroundColor = [UIColor yellowColor]; [self.navigationController.navigationBar addSubview:searchBar]; 回答1: For some reason

Changing the UINavigationBar background image

狂风中的少年 提交于 2019-12-17 09:31:40
问题 I've been trying to change the background image of the UINavigationBar of my application. I tried several ways. First I added to my AppDelegate class the following code: @implementation UINavigationBar (CustomImage) - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed: @"navigationbar.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } @end But it wasn't working. My next try was to write a CustomizedNavigationBar Class which is

UIBarButtonItem with custom view not properly aligned on iOS 7 when used as left or right navigation bar items

不羁的心 提交于 2019-12-17 08:02:42
问题 The following code works up through iOS 6: UIButton *myButton = nil; myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.bounds = CGRectMake(0,0,44,30); // setup myButton's images, etc. UIBarButtonItem *item = nil; item = [[UIBarButtonItem alloc] initWithCustomView:customButton]; This is how the button is supposed to be aligned: However, on iOS 7, the button appears to be offset from the right or left by too many pixels: How can I get my custom bar button items to be aligned