// // HDLEZOPButton.h // EZSDK // // Created by Davin on 2023/6/20. // #import NS_ASSUME_NONNULL_BEGIN /// 控制图片在UIButton里的位置,默认为HDLOPButtonImagePositionLeft typedef NS_ENUM(NSUInteger, HDLEZOPButtonImagePosition) { HDLEZOPButtonImagePositionTop, // imageView在titleLabel上面 HDLEZOPButtonImagePositionLeft, // imageView在titleLabel左边 HDLEZOPButtonImagePositionBottom, // imageView在titleLabel下面 HDLEZOPButtonImagePositionRight, // imageView在titleLabel右边 }; @interface HDLEZOPButton : UIButton /** * 子类继承时重写的方法,一般不建议重写 initWithXxx */ - (void)didInitialize NS_REQUIRES_SUPER; /** * 让按钮的文字颜色自动跟随tintColor调整(系统默认titleColor是不跟随的)
* 默认为NO */ @property(nonatomic, assign) IBInspectable BOOL adjustsTitleTintColorAutomatically; /** * 让按钮的图片颜色自动跟随tintColor调整(系统默认image是需要更改renderingMode才可以达到这种效果)
* 默认为NO */ @property(nonatomic, assign) IBInspectable BOOL adjustsImageTintColorAutomatically; /** * 等价于 adjustsTitleTintColorAutomatically = YES & adjustsImageTintColorAutomatically = YES & tintColor = xxx * @warning 不支持传 nil */ @property(nonatomic, strong) IBInspectable UIColor *tintColorAdjustsTitleAndImage; /** * 是否自动调整highlighted时的按钮样式,默认为YES。
* 当值为YES时,按钮highlighted时会改变自身的alpha属性为ButtonHighlightedAlpha */ @property(nonatomic, assign) IBInspectable BOOL adjustsButtonWhenHighlighted; /** * 是否自动调整disabled时的按钮样式,默认为YES。
* 当值为YES时,按钮disabled时会改变自身的alpha属性为ButtonDisabledAlpha */ @property(nonatomic, assign) IBInspectable BOOL adjustsButtonWhenDisabled; /** * 设置按钮点击时的背景色,默认为nil。 * @warning 不支持带透明度的背景颜色。当设置highlightedBackgroundColor时,会强制把adjustsButtonWhenHighlighted设为NO,避免两者效果冲突。 * @see adjustsButtonWhenHighlighted */ @property(nonatomic, strong, nullable) IBInspectable UIColor *highlightedBackgroundColor; /** * 设置按钮点击时的边框颜色,默认为nil。 * @warning 当设置highlightedBorderColor时,会强制把adjustsButtonWhenHighlighted设为NO,避免两者效果冲突。 * @see adjustsButtonWhenHighlighted */ @property(nonatomic, strong, nullable) IBInspectable UIColor *highlightedBorderColor; /** * 设置按钮里图标和文字的相对位置,默认为HDLOPButtonImagePositionLeft
* 可配合imageEdgeInsets、titleEdgeInsets、contentHorizontalAlignment、contentVerticalAlignment使用 */ @property(nonatomic, assign) HDLEZOPButtonImagePosition imagePosition; /** * 设置按钮里图标和文字之间的间隔,会自动响应 imagePosition 的变化而变化,默认为0。
* 系统默认实现需要同时设置 titleEdgeInsets 和 imageEdgeInsets,同时还需考虑 contentEdgeInsets 的增加(否则不会影响布局,可能会让图标或文字溢出或挤压),使用该属性可以避免以上情况。
* @warning 会与 imageEdgeInsets、 titleEdgeInsets、 contentEdgeInsets 共同作用。 */ @property(nonatomic, assign) IBInspectable CGFloat spacingBetweenImageAndTitle; @property(nonatomic, assign) IBInspectable CGFloat cornerRadius UI_APPEARANCE_SELECTOR;// 默认为 0。将其设置为 HDLOPButtonCornerRadiusAdjustsBounds 可自动保持圆角为按钮高度的一半。 @end NS_ASSUME_NONNULL_END