使用iOS 5外观API的UIBarButtonItemStyleDone背景图片 [英] UIBarButtonItemStyleDone background image using the iOS 5 appearance API

查看:125
本文介绍了使用iOS 5外观API的UIBarButtonItemStyleDone背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用UIBarButtonItemStyleDone样式和编辑/完成按钮的编辑状态为条形按钮提供视觉上不同的条形按钮项目背景图像? UIBarButtonItem外观代理的setBackgroundImage中没有记录的UIControlState值:forState:barMetrics:似乎可以解决问题。

How can I provide a visually distinct bar button item background image for bar buttons with the UIBarButtonItemStyleDone style and the editing state of the Edit/Done button? None of the documented UIControlState values in the UIBarButtonItem appearance proxy's setBackgroundImage:forState:barMetrics: seem to do the trick.

推荐答案

我'我不知道为什么这个从未被回答但如果你还在寻找然后只是在.h中为BarButtonItem创建一个属性,在IB中分配它,然后设置该barButtonItem的背景属性。对我来说工作正常,永远不会改回默认外观。

I'm not sure why this was never answered but if you are still looking then simply create a property for a BarButtonItem in your .h, assign it in IB, then set the background property of that barButtonItem. Works fine for me and never "changes back to default appearance".

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.barButton setBackgroundImage:[UIImage imageNamed:@"YOURIMAGE"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
}

这篇关于使用iOS 5外观API的UIBarButtonItemStyleDone背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆