如何为UIBarButtonItem添加“Glow effect”效果?

3

我尝试了很多方法来找到UIBarButtonItem的发光效果。现在,我通过创建一个UIButton,并将其作为UIBarButton的customView来实现。是否有其他更简单的方法?(例如UIBarButtonItem的内置属性)

2个回答

8
你是指当你触摸一个按钮时得到的效果吗?这是UIButton的一个属性(也可从Interface Builder访问)。
@property(nonatomic) BOOL showsTouchWhenHighlighted

So...

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

如果您编写UIBarButtonItem子类并将此代码放在其中的某个位置,那么重新使用它非常容易(且不会混乱)。我不确定是否有其他方法。

1
朋友,我知道如何使UIButton发光。问题是如何在不将UIButton自定义视图添加到UIBarButton上的情况下添加发光效果。 - thoughtbreaker

0
你尝试过使用 UIBarButtonItemStylePlain 作为按钮样式,使用以下方法之一吗? - (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接