uibarbuttonitem

Changing font color of UIBarButtonItem

寵の児 提交于 2020-06-11 16:53:07
问题 I tried to change the font color of the right bar button item to purple, but it still shows up as white. I've consulted this question and this question. How do I fix this? Code let sortButton = UIButton(frame: CGRect(x: 0, y: 0, width: 34, height: 15)) sortButton.setTitle("SORT", for: .normal) sortButton.titleLabel?.tintColor = UIColor.myMusicPurple sortButton.tintColor = UIColor.myMusicPurple navigationItem.rightBarButtonItem = UIBarButtonItem(customView: sortButton) navigationItem

UIToolbar with UIBarButtonItem LayoutConstraint issue

怎甘沉沦 提交于 2020-06-10 12:52:29
问题 I'm creating a UIToolbar with UIBarButtonItem in it programatically. I'm not using .xib or storyboard for this ViewController. Here's the code of how I created it. NSMutableArray *items = [[NSMutableArray alloc] init]; UIBarButtonItem *buttonItem; buttonItem = [[UIBarButtonItem alloc ] initWithTitle: [Language get:@"Home" alter:nil] style: UIBarButtonItemStyleBordered target: self action: @selector(viewChangeTo)]; [items addObject:buttonItem]; toolbar = [[UIToolbar alloc] init]; toolbar.frame

How do I set title for UIBarButtonItem?

我怕爱的太早我们不能终老 提交于 2020-05-12 11:08:08
问题 I'm a beginner iPhone developer. How can I programmatically set the title for the UIBarButtonItem ? My code is the following: self.navigationItem.rightBarButtonItems = UIBarButtonItem( barButtonSystemItem: .Cancel, target: self, action: "barButtonItemClicked:") @IBAction func barButtonItemClicked(sender: UIBarButtonItem) { //print something } 回答1: Use different initialiser that allows you to specify the title: UIBarButtonItem(title: "title", style: .Plain, target: self, action:

How to animate a button change in UINavigationBar?

巧了我就是萌 提交于 2020-04-08 08:36:50
问题 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

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

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

Set color of one UIBarButtonItem using IBOutlet

こ雲淡風輕ζ 提交于 2020-03-06 02:20:10
问题 I can't seem to find this anywhere on stack because every solution just mentions how you can set your custom appearance through AppDelegate or through setting the appearance . All I need is to set ONE and only this one UIBarButtonItem to a custom hexColor using a method called colorWithHexString: that comes from a class extension(added to the project). my property: @property (weak, nonatomic) IBOutlet UIBarButtonItem *grNextButton; what I'm trying to use in my .m file: grNextButton.tintColor

Set color of one UIBarButtonItem using IBOutlet

爷,独闯天下 提交于 2020-03-06 02:19:32
问题 I can't seem to find this anywhere on stack because every solution just mentions how you can set your custom appearance through AppDelegate or through setting the appearance . All I need is to set ONE and only this one UIBarButtonItem to a custom hexColor using a method called colorWithHexString: that comes from a class extension(added to the project). my property: @property (weak, nonatomic) IBOutlet UIBarButtonItem *grNextButton; what I'm trying to use in my .m file: grNextButton.tintColor

iOS开发技巧(系列十八:扩展UIColor,支持十六进制颜色设置)

僤鯓⒐⒋嵵緔 提交于 2020-02-28 13:54:33
新建一个Category,命名为UIColor+Hex,表示UIColor支持十六进制Hex颜色设置。 UIColor+Hex.h文件, #import <UIKit/UIKit.h> #define RGBA_COLOR(R, G, B, A) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:A] #define RGB_COLOR(R, G, B) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:1.0f] @interface UIColor (Hex) + (UIColor *)colorWithHexString:(NSString *)color; //从十六进制字符串获取颜色, //color:支持@“#123456”、 @“0X123456”、 @“123456”三种格式 + (UIColor *)colorWithHexString:(NSString *)color alpha:(CGFloat)alpha; @end 上面的代码在开头是两个宏定义,就是对[UIColor colorWithRed:green:blue

Add UIBarButtonItem to navigation Bar in Xamarin IOS

百般思念 提交于 2020-02-21 12:53:34
问题 How to add custom UIBarButtonItem to navigationbar rightside. public UIBarButtonItem btn_Cart {get; set;} public DetailedController (){ string buttonTitle = "One"; btn_Cart = new UIBarButtonItem (buttonTitle, UIBarButtonItemStyle.Bordered, null); btn_Cart.Clicked += (s, e) => { new UIAlertView ("click!", "btnOne clicked", null, "OK", null).Show (); }; } public override void ViewDidLoad (){ base.ViewDidLoad (); // Added btn_Cart to RightSide Of Naviation Bar. this.NavigationItem