3

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

4

2 回答 2

8

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

@property(nonatomic) BOOL showsTouchWhenHighlighted

所以...

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

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

于 2011-02-03T13:06:48.130 回答
0

你有没有尝试过

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

作为按钮样式使用UIBarButtonItemStylePlain

于 2011-02-03T10:18:55.400 回答