【问题标题】:How to mimic UIButton Storyboard onClick Blink behaviour如何模仿 UIButton Storyboard onClick Blink 行为
【发布时间】:2015-04-28 03:38:54
【问题描述】:

所以我注意到我在 Storyboard 和 Code 中创建 UIButton 之间存在细微的行为差异。在 Storyboard 中创建时,您会注意到任何 UIButton 都会轻微闪烁以响应用户的点击。

现在,当我在代码中创建 UIButton 时,我注意到它并没有这样做。我的按钮工作正常,但我想添加相同的行为,因为它是一个很好的 UI 功能,可以向用户验证他们的触摸已被识别。

有没有办法将它添加到在代码中创建的 UIButton 中?

【问题讨论】:

    标签: ios xcode swift uibutton storyboard


    【解决方案1】:

    尝试使用

    - (void)setImage:(UIImage *)image forState:(UIControlState)state;

    - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;

    - (void)setTitle:(NSString *)title forState:(UIControlState)state;

    您所在的州可能是UIControlStateHighlighted

    【讨论】:

    • 也许我不明白如何使用它,但似乎我必须为该状态设置图像。我没有要设置的图像,它是一个带有标题文本的 UIButton?
    • 啊啊,没关系。我只是使用 SetTitle() 代替,因为我正在使用标签文本并且成功了。所以我想如果我使用的是可以使用 SetImage() 的图像。感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 2013-12-26
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    相关资源
    最近更新 更多