UIButton
UIButton 点击不生效的问题:
透明度,展示效果。
userInteractionEnabled = YES
是否是顶层视图或者说是否被其他视图覆盖。
父视图是否是可以响应事件的。(比如加到一个UIImageView上面,UIImageView 需要设置userInteractionEnabled = YES)
UIButton 设置内边距
1
2
3// The effect of these properties can be replicated via UIButtonConfiguration.contentInset and UIButtonConfiguration.imageToTitlePadding. They are ignored when a configuration is set.
@property(nonatomic) UIEdgeInsets contentEdgeInsets API_DEPRECATED("This property is ignored when using UIButtonConfiguration", ios(2.0,15.0), tvos(2.0,15.0), visionos(1.0, 1.0)) UI_APPEARANCE_SELECTOR API_UNAVAILABLE(watchos); // default is UIEdgeInsetsZero. On tvOS 10 or later, default is nonzero except for custom buttons.
@property(nonatomic) UIEdgeInsets titleEdgeInsets API_DEPRECATED("This property is ignored when using UIButtonConfiguration", ios(2.0, 15.0), tvos(2.0, 15.0), visionos(1.0, 1.0)) API_UNAVAILABLE(watchos); // default is UIEdgeInsetsZero设置contentEdgeInsets 可以实现按钮宽度自适应撑开。
动图
apng 使用UIImageView 没办法控制只播放动画一次的效果。