How can I add the 'Glow effect' to UIBarButtonItem?

旧时模样 提交于 2019-12-01 09:05:34

You mean the effect you get when you touch an button? That is a property on an UIButton (also accessible from Interface Builder);

@property(nonatomic) BOOL showsTouchWhenHighlighted

So...

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.showsTouchWhenHighlighted = YES;

If you write a subclass of UIBarButtonItem and put this code in there somewhere it is really easy (and not messy) to re-use it. I'm not sure if there is any other way.

Have you tried

- (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action

as button style using UIBarButtonItemStylePlain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!