和不适用于我的自定义imegEdgeInsets课程。我通过笔尖设置插图titleEdgeInsetsUIButton
自定义UIButton类代码
class FilledButton: kButton {
private var bgColor = AppTonalPalette.color(.primary)
private var bgColorPressed = AppTonalPalette.color(.primary).withAlphaComponent(0.88)
private var foregroundColor = AppTonalPalette.color(.onPrimary)
private var bgColorDisabled = UIColor.init("#1F1F1F", alpha: 0.12)
private var foregroundColorDisabled = AppTonalPalette.color(.onSurface)
override func layoutSubviews() {
super.layoutSubviews()
updateViews()
}
func updateViews() {
tintColor = isEnabled ? foregroundColor : foregroundColorDisabled
setTitleColor(isEnabled ? foregroundColor : foregroundColorDisabled, for: .normal)
setTitleColor(isEnabled ? foregroundColor : foregroundColorDisabled, for: .highlighted)
backgroundColor = isEnabled ? (isHighlighted ? bgColorPressed : bgColor) …Run Code Online (Sandbox Code Playgroud)