UIButton
@_spi(FW) extension UIButton
-
加载网络图片,支持占位、选项、回调和进度,优先加载插件,默认使用框架网络库
Declaration
Swift
public func fw_setImage(url: URLParameter?, placeholderImage: UIImage? = nil, options: WebImageOptions = [], context: [ImageCoderOptions : Any]? = nil, completion: ((UIImage?, Error?) -> Void)? = nil, progress: ((Double) -> Void)? = nil)
-
全局自定义按钮高亮时的alpha配置,默认0.5
Declaration
Swift
public static var fw_highlightedAlpha: CGFloat
-
全局自定义按钮禁用时的alpha配置,默认0.3
Declaration
Swift
public static var fw_disabledAlpha: CGFloat
-
自定义按钮禁用时的alpha,如0.3,默认0不生效
Declaration
Swift
public var fw_disabledAlpha: CGFloat { get set }
-
自定义按钮高亮时的alpha,如0.5,默认0不生效
Declaration
Swift
public var fw_highlightedAlpha: CGFloat { get set }
-
自定义按钮禁用状态改变时的句柄,默认nil
Declaration
Swift
public var fw_disabledChanged: ((UIButton, Bool) -> Void)? { get set }
-
自定义按钮高亮状态改变时的句柄,默认nil
Declaration
Swift
public var fw_highlightedChanged: ((UIButton, Bool) -> Void)? { get set }
-
快速设置文本按钮
Declaration
Swift
public func fw_setTitle(_ title: String?, font: UIFont?, titleColor: UIColor?)
-
快速设置文本
Declaration
Swift
public func fw_setTitle(_ title: String?)
-
快速设置图片
Declaration
Swift
public func fw_setImage(_ image: UIImage?)
-
设置图片的居中边位置,需要在setImage和setTitle之后调用才生效,且button大小大于图片+文字+间距
imageEdgeInsets: 仅有image时相对于button,都有时上左下相对于button,右相对于title titleEdgeInsets: 仅有title时相对于button,都有时上右下相对于button,左相对于image
Declaration
Swift
public func fw_setImageEdge(_ edge: UIRectEdge, spacing: CGFloat)
-
图文模式时自适应粗体文本,解决图文按钮文本显示不全(…)的兼容性问题
Declaration
Swift
public func fw_adjustBoldText()
-
设置状态背景色
Declaration
Swift
public func fw_setBackgroundColor(_ backgroundColor: UIColor?, for state: UIControl.State)
-
快速创建文本按钮
Declaration
Swift
public static func fw_button(title: String?, font: UIFont?, titleColor: UIColor?) -> Self
-
快速创建图片按钮
Declaration
Swift
public static func fw_button(image: UIImage?) -> Self
-
设置按钮倒计时,从window移除时自动取消。等待时按钮disabled,非等待时enabled。时间支持格式化,示例:重新获取(%lds)
Declaration
Swift
@discardableResult public func fw_startCountDown(_ seconds: Int, title: String, waitTitle: String) -> DispatchSourceTimer