uinavigationbar

How to animate a button change in UINavigationBar?

自闭症网瘾萝莉.ら 提交于 2020-04-08 08:36:01
问题 I am calling the -(void)setEditing:(BOOL)editing animated:(BOOL)animated method in my code to swap between two buttons on the RHS of my navigation bar. -(void)setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; // Toggle ‘+’ and ‘Add To Order’ button. if( editing ) { self.navigationItem.rightBarButtonItem = self.addItemButton; } else { self.navigationItem.rightBarButtonItem = self.addToOrderButton; } } Where self.addItemButton and self

Searchbar behind Navigationbar

徘徊边缘 提交于 2020-03-25 19:00:30
问题 Given 3 Controllers: A,B,C A has a hidden navigationbar. Calls Controller B via a StoryboardReference. Controller B shows Navigationbar on viewDidLoad. It has a searchbar and a collectionView. See screenshot A of my storyboard. Calls controller C if a cell is clicked. Problem: If A calls B the searchbar is behind the navigationbar (Screenshot B). It appears with the transition from C to B (Screenshot C). Navigationbar is already translucent. Any ideas? EDIT I realized that my animated

Searchbar behind Navigationbar

亡梦爱人 提交于 2020-03-25 19:00:16
问题 Given 3 Controllers: A,B,C A has a hidden navigationbar. Calls Controller B via a StoryboardReference. Controller B shows Navigationbar on viewDidLoad. It has a searchbar and a collectionView. See screenshot A of my storyboard. Calls controller C if a cell is clicked. Problem: If A calls B the searchbar is behind the navigationbar (Screenshot B). It appears with the transition from C to B (Screenshot C). Navigationbar is already translucent. Any ideas? EDIT I realized that my animated

Left bar button Item

◇◆丶佛笑我妖孽 提交于 2020-03-19 05:39:32
问题 so if you have a navigation controller with no bar button Items then a navigation back button will show up with the name of the last View Controller and I want to keep that, as in I don't want to have to hardCode it. and I do know how to add it in but I don't want to have to do that because that leaves more room for bugs. Is there a way that I can have a left bar button Item and the default one doesn't go away? 回答1: Add this in viewController where you want to have default back button and

Make SwiftUI navigation bar transparent

。_饼干妹妹 提交于 2020-02-28 07:54:34
问题 I'm searching for a way to make the NavigationBar transparent. My NavigationView is in the root view in ContentView which contains a TabView. import SwiftUI struct ContentView: View { var body: some View { TabView { HomeView().tabItem { Image(systemName: "house.fill") Text("Home") }.tag(1) NavigationView { SearchView() } .tabItem { Image(systemName: "magnifyingglass") Text("Search") }.tag(2) } The NavigationView Bar displays even after adding the following modifier in the root view. init() {

Add a button to large title navigation bar

时间秒杀一切 提交于 2020-02-17 05:42:05
问题 Summary I'd like to add a button to a large title navigation bar like App Store's account button. Flow Desired: Button is visible only when large titles is enabled Allow transition from large titles to normal when user scrolls inside the view. Note: I use storyboard. 回答1: Found the answer on this Medium article by Tung Fam. private let imageView = UIImageView(image: UIImage(named: "image_name")) /// WARNING: Change these constants according to your project's design private struct Const { ///

MKMapView makes the navigation bar gets transparent

狂风中的少年 提交于 2020-01-29 02:54:25
问题 I am porting my existing iOS 6 application to the new iOS 7. But whenever a MKMapView instance appears into the screen, my navigation bar loses its tint color. Steps to reproduce: Open Xcode; Create a new Master-Detail Application; Add the next line as the first one of the AppDelegate.m didFinishLaunchingWithOptions method: [[UINavigationBar appearance] setBarTintColor:[UIColor redColor]] Add the next line to the MasterViewController.m file: #import <MapKit/MapKit.h> Finally, add the next

Navigation gap appears When transition from Large title Page to small Title Page

六月ゝ 毕业季﹏ 提交于 2020-01-25 10:10:32
问题 Navigation gap appears when swipe from large title page to small title page! 回答1: Make sure, you just need to check Translucent selected from the storyboard. Set in code like this override func viewWillAppear(_ animated: Bool) { if #available(iOS 11.0, *) { self.navigationController?.navigationBar.prefersLargeTitles = true self.navigationController?.navigationItem.largeTitleDisplayMode = .automatic // Change Display Mode }else{ // Fallback on earlier versions } } Outout : 回答2: The view's

Padding wrong when presenting second modal navigation controller on iOS 13

自闭症网瘾萝莉.ら 提交于 2020-01-25 06:49:14
问题 On iOS 13, when presenting a second modal view controller over a first one, the padding is incorrect on the button bar items. In particular, the right margin disappears. How should this be fixed? 回答1: This behavior is due to a bug in iOS 13. It can be fixed by calling setNeedsLayout on the Navigation Bar. Swift example: override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if #available(iOS 13.0, *) { navigationController?.navigationBar.setNeedsLayout() } } Objective

use [UINavigationBar appearance] to change back button image

折月煮酒 提交于 2020-01-23 11:52:04
问题 I'd like to change the back button of my UINavigationBar I can do it using this code: // Set the custom back button UIImage *buttonImage = [UIImage imageNamed:@"backag.png"]; //create the button and assign the image UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:buttonImage forState:UIControlStateNormal]; [button setImage:[UIImage imageNamed:@"selback.png"] forState:UIControlStateHighlighted]; button.adjustsImageWhenDisabled = NO; //set the frame of the