iPhone UIToolbar UIButtonItem 突出显示
我对 UIToolbar
进行了子类化,并在其中创建了一组 UIButtonItems
,所有这些都按顺序添加,并且具有灵活的空间。我现在想在每次点击时切换 UIButtonItems
之一(就像 iPod 中的随机播放按钮一样,白蓝白蓝。我保留了对 UIButtonItem
的引用) 。
// interface
UIButtonItem *_shuffleButton; // released in dealloc
// implementation
UIImage *_shuffleButtonImage = [UIImage imageNamed:@"shuffle_icon_200x100.png"];
_shuffleButton = [[UIBarButtonItem alloc] initWithImage:_shuffleButtonImage style:UIBarButtonItemStylePlain target:self action:@selector(shuffleButtonTapped)];
所以现在在 shuffleButtonTapped
中,我想做一些类似的事情:
_shuffleButton.highlighted = YES;
// or
_shuffleButton.selected = YES;
但是这些工作
我都没有找到任何东西,我开始认为我错过了一些东西,谁能告诉我 我可能是什么?谢谢。
I have subclassed UIToolbar
and within it have created a set of UIButtonItems
, all added in order and nicely spaced with flexible spaces. I now want to toggle one of the UIButtonItems
each time it is tapped (just like the shuffle button in iPod, white blue white blue. I have maintained a reference to the UIButtonItem
.
// interface
UIButtonItem *_shuffleButton; // released in dealloc
// implementation
UIImage *_shuffleButtonImage = [UIImage imageNamed:@"shuffle_icon_200x100.png"];
_shuffleButton = [[UIBarButtonItem alloc] initWithImage:_shuffleButtonImage style:UIBarButtonItemStylePlain target:self action:@selector(shuffleButtonTapped)];
So now in shuffleButtonTapped
I want to do something like:
_shuffleButton.highlighted = YES;
// or
_shuffleButton.selected = YES;
but neither of these work.
I have searched high and low and after failing to find anything I am starting to think I am missing something, can anyone tell me what it might be?? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我创建自己的
navigationItem
按钮的方法,该按钮实际上是一个视图,可以像任何其他视图一样进行动画处理。Here is what I did to create my own
navigationItem
Button which is in fact a view and can be animated just like any other view.如果您只想将简单的图像显示为按钮,请改用 UITabBar。它将自动更改选择 UI。
if you just want to show wome simple images as a buttons, use UITabBar instead. It will make selection UI changes automatically.