ToolbarButton

@MainActor
open class ToolbarButton : UIButton

自定义工具栏按钮,使用非等比例缩放布局,兼容系统customView方式和自定义方式

UIBarButtonItem自定义导航栏时最左和最右间距为16,系统导航栏时为8; ToolbarButton作为customView使用时,会自动调整按钮内间距,和系统表现一致; ToolbarButton自动适配横竖屏切换,竖屏时默认内间距{8, 8, 8, 8},横屏时默认内间距{0,8,0,8}

  • UIBarButtonItem默认都是跟随tintColor的,所以这里声明是否让图片也是用AlwaysTemplate模式,默认YES

    Declaration

    Swift

    @MainActor
    open var adjustsTintColor: Bool { get set }
  • 指定标题初始化,自适应内边距,可自定义

    Declaration

    Swift

    @MainActor
    public convenience init(title: String?)
  • 指定图片和标题初始化,自适应内边距,可自定义

    Declaration

    Swift

    @MainActor
    public convenience init(image: UIImage?, title: String? = nil)
  • 指定对象初始化,支持UIImage|NSAttributedString|NSString(默认),同时添加点击事件

    Declaration

    Swift

    @MainActor
    public convenience init(object: Any?, target: Any?, action: Selector?)
  • 指定对象初始化,支持UIImage|NSString(默认),同时添加点击句柄

    Declaration

    Swift

    @MainActor
    public convenience init(object: Any?, block: (@MainActor @Sendable (Any) -> Void)?)
  • Undocumented

    Declaration

    Swift

    @MainActor
    override public init(frame: CGRect)
  • Undocumented

    Declaration

    Swift

    @MainActor
    public required init?(coder: NSCoder)
  • Undocumented

    Declaration

    Swift

    @MainActor
    override open func setImage(_ image: UIImage?, for state: UIControl.State)
  • Undocumented

    Declaration

    Swift

    @MainActor
    override open func tintColorDidChange()
  • Undocumented

    Declaration

    Swift

    @MainActor
    override open func layoutSubviews()