如何模仿 UIButton Storyboard onClick Blink 行为

How to mimic UIButton Storyboard onClick Blink behaviour

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

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

有没有办法将其添加到代码中创建的 UI 按钮?

尝试使用

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

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

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

你所在的州UIControlStateHighlighted