iPhone自定义导航栏编辑按钮
我使用以下代码为导航栏按钮使用自定义图像,这允许我制作自定义添加按钮。我希望能够对编辑按钮项目执行相同的操作。
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 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 edit 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以像自定义任何其他导航控制按钮一样自定义编辑按钮,例如...
不幸的是,更改文本颜色并不像设置“颜色”属性那么容易,因为该属性不存在(同样)这适用于所有导航控制按钮)。但是,可以使用以下帖子中描述的标签...
iPhone 导航栏标题文字颜色
You can customize the edit button in the same way you can customize any other navigation control button, for example...
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