uinavigationitem

Custom Nav Title offset ios 11

a 夏天 提交于 2020-01-04 09:38:32
问题 I have a custom navigation item title that is simply two labels, one on top of the other, loaded from a .xib file. It's loaded by calling this: class Utilities { /// Title and subtitle format custom title in Navigation bar. Top and bottom text are centered on one another. /// /// - Parameters: /// - navigationItem: The receiving controller's navigation item. /// - titleText: Top text to be displayed a little larger and more bold. /// - subtitleText: Bottom text to be displayed a little

Custom Title View not Centered in iOS 10

半城伤御伤魂 提交于 2020-01-04 05:21:34
问题 This post is a separate topic but related to Custom Nav Title offset ios 11 I created a new thread because it is a separate issue. From project: https://github.com/ekscrypto/Swift-Tutorial-Custom-Title-View To recreate the problem, simply put a button on the existing Root View Controller that pushes another view controller. The "< Back" button scoots the title over, which makes it terribly uncentered. How can I fix this? Thank you. 回答1: Simple change required to support earlier versions of

Create UIBarButtonItem with back button style

别来无恙 提交于 2020-01-04 04:00:32
问题 I'm looking for a way to create programmatically an UIBarButtonItem that looks like a back button of UINavigationBar . Apparently seems like that the back button appears only after a push on the UINavigationController . So I'm able to insert only a button with the "cancel" style. But my goal is to create a button with the "New Item" style. Ideas ? 回答1: the short answer is you cannot do it. you can save an image and you can put the image to that position, but the back button is managed by

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 to prevent Large Title from Collapsing

吃可爱长大的小学妹 提交于 2020-01-01 09:14:06
问题 The question is simple, how can I prevent a Large Title Navigation Bar from collapse when a scrollview scrolls down? My navigation must have a large navigation bar at all times... so when a scrollview scroll, the navigation bar shouldn't collapse up, it should stay the same size, how can I do that? This is how I set the largeTitle preferences override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.navigationItem.hidesBackButton = true presenter

Localize Done button of MPMoviePlayerViewController

不问归期 提交于 2019-12-30 09:29:14
问题 I am using a MPMoviePlayerViewController to present videos. Everything works as expected, but if I switch the device's language to e.g. German, the "Done" button is not localized. I tried to access the button and set it to my own button implementation like so: MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; NSLog(@"%@", mp.navigationItem.leftBarButtonItem); // always null, but why? // override button with locale mp.navigationItem

Change navigation bar bottom border color Swift

核能气质少年 提交于 2019-12-30 03:49:10
问题 It works with import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default) self.navigationController?.navigationBar.shadowImage = UIColor.redColor().as1ptImage() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be

UIButton in Navigation Bar Not Recognizing Taps in iOS 11

痞子三分冷 提交于 2019-12-29 06:56:49
问题 I have a UIButton in a navigation bar that sits over the top of a UIImage and a UILabel . It worked fine in iOS 10, but now in iOS 11 it doesn't recognize any taps from my @IBAction outlet. I tried moving the tap outlet to the bar button item, but that didn't work either. The UIButton has the following constraints: I confirmed that it's there by giving it a green background, so I know it's visible and available. Any idea what's going on? 回答1: I found a solution from another developer. You

UIButton in Navigation Bar Not Recognizing Taps in iOS 11

倖福魔咒の 提交于 2019-12-29 06:56:11
问题 I have a UIButton in a navigation bar that sits over the top of a UIImage and a UILabel . It worked fine in iOS 10, but now in iOS 11 it doesn't recognize any taps from my @IBAction outlet. I tried moving the tap outlet to the bar button item, but that didn't work either. The UIButton has the following constraints: I confirmed that it's there by giving it a green background, so I know it's visible and available. Any idea what's going on? 回答1: I found a solution from another developer. You

Get the frame of UIBarButtonItem in Swift?

99封情书 提交于 2019-12-28 06:29:08
问题 how could I get the frame of a rightbarbuttonItem in swift? I found this : UIBarButtonItem: How can I find its frame? but it says cannot convert NSString to UIView, or cannot convert NSString to String : let str : NSString = "view" //or type String let theView : UIView = self.navigationItem.rightBarButtonItem!.valueForKey("view")//or 'str' The goal is to remove the rightBarButtonItem, add an imageView instead, and move it with a fadeOut effect. Thanks 回答1: You should try it like: var