【发布时间】:2011-02-03 09:49:54
【问题描述】:
我尝试了很多方法来找出 UIBarButtonItem 的发光效果。现在正在创建一个 UIButton 并将其作为 UIBarButton 的 customView。有没有人有任何其他方法可以使它更容易? (就像 UIBarButtonItem 的内置属性)
【问题讨论】:
标签: iphone ipad uibutton uibarbuttonitem glow
我尝试了很多方法来找出 UIBarButtonItem 的发光效果。现在正在创建一个 UIButton 并将其作为 UIBarButton 的 customView。有没有人有任何其他方法可以使它更容易? (就像 UIBarButtonItem 的内置属性)
【问题讨论】:
标签: iphone ipad uibutton uibarbuttonitem glow
你的意思是当你触摸一个按钮时得到的效果?这是 UIButton 上的一个属性(也可以从 Interface Builder 访问);
@property(nonatomic) BOOL showsTouchWhenHighlighted
所以...
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.showsTouchWhenHighlighted = YES;
如果您编写 UIBarButtonItem 的子类并将此代码放在某个地方,那么重用它真的很容易(而且不会乱七八糟)。不知道有没有其他办法。
【讨论】:
你试过了吗
- (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
使用UIBarButtonItemStylePlain作为按钮样式
【讨论】: