Tag: uinavigationbar

如何使UINavigationBar背景透明?

首先,我已经看到了如何在iOS 8中使UINavigationBar透明的所有答案? 透明UINavigationBar并使UINavigationBar透明 。 他们似乎没有为我工作。 我常规的视图控制器(试图使导航栏透明之前)没有任何问题: 我正在使用(尝试在viewDidLoad和viewWillAppear: : [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; self.navigationController.navigationBar.shadowImage = [UIImage new]; self.navigationController.navigationBar.translucent = YES; self.navigationController.view.backgroundColor = [UIColor clearColor]; 我得到这个: 灰色状态栏背景,完全白色的导航栏不与状态栏混合,然后视图开始。 在其他问题“答案”中的所有“解决scheme”对我来说都会产生相同的结果。 我也试过设置self.edgesForExtendedLayout = UIRectEdgeNone; 或self.edgesForExtendedLayout = UIRectEdgeAll; 但这也没有任何影响。 我怎样才能使我的导航栏透明而不会搞乱一切? 更新:继瓦里夫·阿赫德·里希的回答后,我改变了self.navigationController.view.backgroundColor = [UIColor clearColor]; to self.navigationController.navigationBar.backgroundColor = [UIColor clearColor]; ,现在我得到一个灰色,统一的状态/导航条,但仍然不透明: 更新2:我已经连接了视图debugging器,而且灰色背景似乎来自视图层次结构的深层,而我的视图的内容并没有扩展。 我试过self.edgesForExtendedLayout = UIRectEdgeAll; 再次与最新的代码,但仍然无济于事:

在AppDelegate中使用Swift UINavigationBar setBackgroundImage

我试图设置一个背景图像全球导航栏中的应用程序委托在Swift中。 我可以让它在单独的View Controller上工作,像这样: var topBar: UINavigationBar! topBar.setBackgroundImage(UIImage(named: "navbar"), forBarMetrics: .Default) 但是,当我尝试将以下内容添加到应用程序委托,它崩溃与未捕获的exception: UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navbar"), forBarMetrics: .Default)

如何增加UINavigationBar的高度?

简单的问题:我怎样才能增加导航栏的高度,使附加的小部件将适合在那里, 同时保持模糊? 示例是日历应用程序,其中工作日缩写添加到导航栏的底部。 …和邮件中,当您将邮件移动到不同的文件夹时:

如何在swift ios中的导航栏标题中使用图像

我有麻烦了。 我想在导航栏标题中使用图像,但我得到一个错误,即“UIImage”不是“NSString”的子types。 在代码下面,看看它。 class Dashboard: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.navigationItem.title = UIImage(named: "logo.png") // Do any additional setup after loading the view. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } 任何人可以build议? 谢谢!

UINavigationBar滑开,而不是留在原地

我创build了演示项目来显示问题。 我们在UINavigationController里有两个视图控制器。 MainViewController是根。 class MainViewController: UIViewController { lazy var button: UIButton = { let button = UIButton() button.setTitle("Detail", for: .normal) return button }() override func viewDidLoad() { super.viewDidLoad() navigationItem.title = "Main" view.backgroundColor = .blue view.addSubview(button) button.translatesAutoresizingMaskIntoConstraints = false button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true button.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true button.widthAnchor.constraint(equalToConstant: 150).isActive = true button.heightAnchor.constraint(equalToConstant: 42).isActive = true button.addTarget(self, […]

leftbarbuttonitem不显示在导航栏中

我一直在开发一个iOS应用程序,并一直在使用图像作为导航栏中的左栏button项的问题。 我尝试了以下方法: UIImage *backButtonImage = [UIImage imageNamed:@"backbuttonCB"]; CGRect buttonFrame = CGRectMake(0, 0, backButtonImage.size.width, backButtonImage.size.height); UIButton *backButton = [[UIButton alloc] initWithFrame:buttonFrame]; [backButton setImage:backButtonImage forState:UIControlStateNormal]; UIBarButtonItem *backBarButtonItem= [[UIBarButtonItem alloc] initWithCustomView: backButton]; self.navigationItem.leftBarButtonItem = backBarButtonItem; 酒吧button似乎永远不会显示在运行应用程序。 然后,我继续尝试下面的其他方法。 self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"backbuttonCB"] style:UIBarButtonItemStylePlain target:nil action:@selector(methodname)]; 这个方法实际上工作。 然而,显示的图像是蓝色的,看起来不像是这个意思。 改变这个图像的色调并没有帮助。 任何想法如何我可以解决这个问题? 编辑:更多的信息,如果有帮助。 这是导航堆栈中的第一个视图。 导航堆栈以模态方式显示,即存在先前的视图控制器,并且在先前的视图控制器和导航控制器之间存在模态延续。 这是导航堆栈中的第一个视图。 编辑:问题是固定的。 我认为这是一个在Xcode中的错误,因为当我重新启动Xcode并用实际的设备而不是模拟器testing它,它工作正常。 但是,似乎仍然不能在仿真器上工作。

更改导航上一步button的目的地

如何更改视图控制器的默认导航后退button带我到? 后退button通常会将您带回到先前的视图控制器。 但是如果我想让它回到两个视图控制器呢? 我的意思是我想改变视图控制器的后退button带我。 我不喜欢创build一个自定义后退button。 那还有别的办法吗? 可能是一个放松的继续链接到后退button什么的?

如何以编程方式删除UINavigationbar提示?

我有一个视图控制器,并在IB中用提示设置导航栏。 但是我想删除这个提示,有时候把它作为“1行”。 我怎么能在代码中做到这一点?

如何更改UIBarButtonItem的tintColor?

我想将我的右栏button项目的颜色从黑色更改为白色。 这是一个button作为search图标。 我还没有对search实现进行编码,因为我想先完成主界面。 我以为我写了正确的代码,所以它应该显示为白色,但在故事板和模拟器中似乎仍然显示为黑色。 在故事板中,我也把它设置为白色。 这是我的代码,位于AppDelegate.swift文件中: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Changing the status bar's colour to white UIApplication.sharedApplication().statusBarStyle = .LightContent // Changing the navigation controller's background colour UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255.0, green: 165.0/255.0, blue: 227.0/255.0, alpha: 1.0) // Changing the navigation controller's title colour UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()] […]

使用自定义字体时,UINavigationBar标题会被截断

在使用此代码来自定义UINavigationBar标题外观之后,带有文本的标签将被截断,如下图所示: [[UINavigationBar appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor whiteColor], UITextAttributeFont : [UIFont fontWithName:@"Intro" size:20.0f], UITextAttributeTextShadowColor : [UIColor clearColor] }]; 而且,你可以看到,有足够的空间。 有任何想法吗?