【问题标题】:How can I add the 'Glow effect' to UIBarButtonItem?如何将“发光效果”添加到 UIBarButtonItem?
【发布时间】:2011-02-03 09:49:54
【问题描述】:

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

【问题讨论】:

    标签: iphone ipad uibutton uibarbuttonitem glow


    【解决方案1】:

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

    @property(nonatomic) BOOL showsTouchWhenHighlighted
    

    所以...

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

    如果您编写 UIBarButtonItem 的子类并将此代码放在某个地方,那么重用它真的很容易(而且不会乱七八糟)。不知道有没有其他办法。

    【讨论】:

    • 朋友,我知道让 UIButton 发光的方法。问题是如何在不自定义 UIButton 的情况下向 UIBarButton 添加发光效果。
    【解决方案2】:

    你试过了吗

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

    使用UIBarButtonItemStylePlain作为按钮样式

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-24
      • 2017-03-14
      • 2010-11-30
      • 2011-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多