uibarbuttonitem

UIBarButtonItem appearance trouble in iOS 7, could this be an Apple bug?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 06:37:16
I saw an article a while back, which is here: User Interface Customization in iOS 6 It shows customization for iOS 6. Since the article I have written Apps that use the technique, it is pretty straightforward, no magic in there. However, I need to update one of my apps and under iOS 7 it does not work correctly. It appears that customization of UIBarButtonItems does not work the first time the view is presented. If I dismiss the view and then present it agin everything works fine. What is seen is shown here: First time view is presented: Second time: I have seen this issue in his example, my

How to add UIBarButtonItem to NavigationBar while using UIPageViewController

帅比萌擦擦* 提交于 2019-12-03 03:32:38
Please forgive me, there are already a ton of questions on how to add a UIBarButtonItem to a NavigationBar programmatically but I just can't seem to get any of the solutions to work in my situation. Here is the layout of a simple test app I have been working with to learn the UIPageViewController. I have the page view controller working nicely with three unique viewControllers. I would now like to set unique rightBarButtonItems for each of the view controllers. I can easily set a common barButtonItem in the DetailViewController by simply doing this. UIBarButtonItem *newButton = [

Swift Custom NavBar Back Button Image and Text

。_饼干妹妹 提交于 2019-12-03 02:36:39
问题 I need to customise the look of a back button in a Swift project. Here's what I have: Here's what I want: I've tried creating my own UIBarButtonItem but I can't figure out how to get the image to be beside the text, rather than as a background or a replacement for the text. let backButton = UIBarButtonItem(title: "Custom", style: .Plain, target: self, action: nil ) //backButton.image = UIImage(named: "imageName") //Replaces title backButton.setBackgroundImage(UIImage(named: "imageName"),

How to add multiple UIBarButtonItems on right side of Navigation Bar?

独自空忆成欢 提交于 2019-12-03 01:17:57
问题 I would like to have more than a single UIBarButtonItem on the right side of my UINavigationBar . How can I achieve this? An example of what I am trying are shown below - you can notice that the top right has more than one button. 回答1: Use this in swift: override func viewDidLoad() { super.viewDidLoad() let editImage = UIImage(named: "plus")! let searchImage = UIImage(named: "search")! let editButton = UIBarButtonItem(image: editImage, style: .Plain, target: self, action: "didTapEditButton:")

Persistent rightBarButtonItem Property of UINavigationItem

点点圈 提交于 2019-12-03 00:23:12
This may be a stupid question, but is it possible to keep a right UIBarButtonItem across multiple views managed by a UINavigationController ? I have a progression of views that often share the same right UIBarButtonItem , but when I push a new view to my UINavigationController , I have to redefine the button every time, even if it hasn't changed. Mostly, the noticeable transitional animation from one view to the next is what bothers me because the exact same button briefly fades out then back in, which is unnecessary since there is no actual visual change. Should I consider just adding a

Swift exclamation mark before a text

ⅰ亾dé卋堺 提交于 2019-12-02 23:33:13
问题 This tutorial I am currently working on says I have to disable the Save Button until the text field has some value in it. Here is the code: saveButton.isEnabled = !text.isEmpty Does the exclamation mark before text.isEmpty mean that the save button is enabled is the text is not empty same way that != mean not equal to? I know exclamation mark means force unwrap, but I thought you put the exclamation mark after the text. BTW(I have tested it and it works as the tutorial says so) 回答1: The

Swift add badge to navigation barButtonItem and UIButton

喜夏-厌秋 提交于 2019-12-02 22:00:52
I am trying to display badge on my notification button, in app as displayed on AppIcon. So far whatever i have researched is related to Obj. C, but nothing that specifically discussed way to implement that solution into Swift, Please help to find a solution to add a custom class / code to achieve Badge on UiBarbutton and UiButton. Researched so far: https://github.com/Marxon13/M13BadgeView along with MKBadge class etc. Working Solution : Step 1: Firstly create new swift file which is a subclass to UIButton as follows: import UIKit class BadgeButton: UIButton { var badgeLabel = UILabel() var

How do you set the font size on a UIBarButtonItem?

不问归期 提交于 2019-12-02 21:48:52
I can't find a way to set the font size of the title in a custom UIBarButtonItem. The only way I can think of getting around this is to set it as an image which I would like to avoid. Any other suggestions? In a easy way, simply: Objective-C: NSUInteger fontSize = 20; UIFont *font = [UIFont boldSystemFontOfSize:fontSize]; NSDictionary *attributes = @{NSFontAttributeName: font}; UIBarButtonItem *item = [[UIBarButtonItem alloc] init]; [item setTitle:@"Some Text"]; [item setTitleTextAttributes:attributes forState:UIControlStateNormal]; self.navigationItem.rightBarButtonItem = item; Swift: let

iOS7 UILabel to adopt same tintColor as window

泄露秘密 提交于 2019-12-02 20:54:43
I know that for elements of classes UIButton and UIBarButtonItem they automatically assume window.tintColor as the main colour, which results of an immediate change in case I set a new tintColor to window at any time in the app. I was wondering if there is any way to make UILabel elements to follow the same pattern, where once created they automatically assumer its default colour as window.tintColor and if changing window.tintColor at any time within my app runtime would also result in changing the UILabel tintColour automatically? I hope that makes sense. UILabels are a subclass of UIView ,

iOS 5: How to implement a custom (image) back button

好久不见. 提交于 2019-12-02 19:32:15
I've done the tutorial at my blog, so I know how to make a stretchable button that can display the bottom (stack) viewcontroller's title. But what I was hoping to do is have icons (like a house for HOME) and no text and not resize. Using my custom image and this code below, I get a stretched version (not wanted) with title over top (not wanted) and it does tint/highlight when clicked (is good); UIImage *backButtonImage = [UIImage imageNamed:@"backButton_30.png"]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics