开发者

iphone custom navigation bar edit button

开发者 https://www.devze.com 2022-12-29 23:59 出处:网络
I use custom image for my navigation bar buttons using the following code, that allows me to make custom add button. I want to be able to do the same for the ed开发者_StackOverflowit button item.

I use custom image for my navigation bar buttons using the following code, that allows me to make custom add button. I want to be able to do the same for the ed开发者_StackOverflowit button item.

UIImage *image=[UIImage imageNamed:@"Plus.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.bounds = CGRectMake( 0, 0, image.size.width, image.size.height );    
[button setBackgroundImage:image forState:UIControlStateNormal];
[button addTarget:self action:@selector(add) forControlEvents:UIControlEventTouchUpInside];    
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.rightBarButtonItem = barButtonItem;
[barButtonItem release];

self.navigationItem.leftBarButtonItem = self.editButtonItem;

I'm doing this because I want to change the button text color.I would appreciate your help,

Sarah


You can customize the edit button in the same way you can customize any other navigation control button, for example...

self.editButtonItem.style = UIBarButtonItemStyleBordered;
self.editButtonItem.title = @"Custom";
self.navigationItem.rightBarButtonItem = self.editButtonItem;

Unfortunately changing the text colour is not as easy as setting a 'color' property, since that property doesn't exist (again this applies to all navigation control buttons). It is however possible using a label as described in the following post...

iPhone Navigation Bar Title text color

0

精彩评论

暂无评论...
验证码 换一张
取 消