如何将"Glow效果"添加到UIBarButtonItem?

tho*_*ker 3 iphone uibutton uibarbuttonitem glow ipad

我尝试了很多来找出UIBarButtonItem的发光效果.现在我正在创建一个UIButton并将其作为UIBarButton的customView.有没有人有任何其他方法可以让它更容易?(就像UIBarButtonItem的内置属性)

Jak*_*ake 8

你的意思是你触摸按钮时的效果?这是UIButton上的属性(也可以从Interface Builder访问);

@property(nonatomic) BOOL showsTouchWhenHighlighted
Run Code Online (Sandbox Code Playgroud)

所以...

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.showsTouchWhenHighlighted = YES;
Run Code Online (Sandbox Code Playgroud)

如果您编写UIBarButtonItem的子类并将此代码放在某处,则重新使用它非常容易(而不是凌乱).我不确定是否还有其他办法.