更改UIBarButtonSystem颜色

时间:2012-02-23 22:17:08

标签: iphone objective-c ios ipad

是否可以更改UIBarButtonSystemItemPlay或其他任何系统按钮的颜色?我检查了文档,但没有办法这样做。

2 个答案:

答案 0 :(得分:1)

正如戴夫所说,你可以改变任何UIBarButtonItem的色调颜色。如果您在IB中添加按钮,则必须在Inspector中的属性下。在条形按钮项下,您可以决定样式和色调颜色。

或者,我在这里以编程方式将褐色播放按钮添加到工具栏。

UIBarButtonItem *play =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay 
                                                                     target:self 
                                                                     action:@selector(playSomething)]; // if you want to do something when play pressed
[play setStyle:UIBarButtonItemStylePlain]; // Other options are UIBarButtonItemStyleDone or UIBarButtonItemStyleBordered
[play setTintColor:[UIColor brownColor]]; // or whatever color u like


NSArray *items = [[NSArray alloc] initWithObjects:play /*Other buttons like UIBarButtonSystemItemFlexibleSpace can go here*/, nil];

[self setToolbarItems:items];

请记住,您可以根据需要使用颜色,按钮等进行创作。我个人更喜欢使用UIBarButtonItem的小图像图标。

希望有所帮助......

答案 1 :(得分:0)

您可以在iOS 5中更改UIBarButtonItem的tint color