ToastView

@MainActor
open class ToastView : UIControl

吐司视图,默认背景色透明

Accessor

  • 当前吐司类型,默认custom,切换时需优先设置

    Declaration

    Swift

    @MainActor
    open var type: ToastViewType { get set }
  • 关联吐司样式,仅用于判断,默认default

    Declaration

    Swift

    @MainActor
    open var style: ToastStyle
  • 吐司位置,默认center

    Declaration

    Swift

    @MainActor
    open var position: ToastViewPosition
  • 自定义视图,仅Custom生效

    Declaration

    Swift

    @MainActor
    open var customView: UIView? { get set }
  • 内容背景色,默认#404040

    Declaration

    Swift

    @MainActor
    open var contentBackgroundColor: UIColor
  • 内容视图最小外间距,默认{10, 10, 10, 10}

    Declaration

    Swift

    @MainActor
    open var contentMarginInsets: UIEdgeInsets
  • 内容视图内间距,默认{10, 10, 10, 10}

    Declaration

    Swift

    @MainActor
    open var contentInsets: UIEdgeInsets
  • 视图和文本之间的间距,默认5.0

    Declaration

    Swift

    @MainActor
    open var contentSpacing: CGFloat
  • 文本和消息之间的间距,默认5.0

    Declaration

    Swift

    @MainActor
    open var textSpacing: CGFloat
  • 内容圆角半径,默认5.0

    Declaration

    Swift

    @MainActor
    open var contentCornerRadius: CGFloat
  • 是否水平对齐,默认NO垂直对齐

    Declaration

    Swift

    @MainActor
    open var horizontalAlignment: Bool
  • 自定义内容垂直偏移,默认nil时自动处理,center时为-30,top时为10,bottom时为-10

    Declaration

    Swift

    @MainActor
    open var verticalOffset: CGFloat?
  • 自定义内容垂直偏移句柄,参数为内容高度,默认nil

    Declaration

    Swift

    @MainActor
    open var verticalOffsetBlock: ((CGFloat) -> CGFloat)?
  • 标题字体,默认16号

    Declaration

    Swift

    @MainActor
    open var titleFont: UIFont
  • 标题颜色,默认白色

    Declaration

    Swift

    @MainActor
    open var titleColor: UIColor
  • 消息字体,默认15号

    Declaration

    Swift

    @MainActor
    open var messageFont: UIFont
  • 消息颜色,默认白色

    Declaration

    Swift

    @MainActor
    open var messageColor: UIColor
  • 指示器图片,支持动画图片,自适应大小,仅Image生效

    Declaration

    Swift

    @MainActor
    open var indicatorImage: UIImage?
  • 指示器大小,默认根据类型处理

    Declaration

    Swift

    @MainActor
    open var indicatorSize: CGSize
  • 指示器颜色,默认nil时不处理,仅Indicator生效

    Declaration

    Swift

    @MainActor
    open var indicatorColor: UIColor? { get set }
  • 带属性标题文本,为空时不显示

    Declaration

    Swift

    @MainActor
    open var attributedTitle: NSAttributedString? { get set }
  • 带属性消息文本,为空时不显示

    Declaration

    Swift

    @MainActor
    open var attributedMessage: NSAttributedString? { get set }
  • 当前指示器进度值,范围0~1,仅Progress生效

    Declaration

    Swift

    @MainActor
    open var progress: CGFloat { get set }
  • 手动点击取消时触发的句柄,默认nil不可点击取消

    Declaration

    Swift

    @MainActor
    open var cancelBlock: (() -> Void)? { get set }
  • 当吐司视图禁止交互时,是否允许contentView可穿透点击,默认false

    Declaration

    Swift

    @MainActor
    open var contentPenetrable: Bool

Subviews

  • 内容视图,可设置背景色(默认#404040)、圆角(默认5),只读

    Declaration

    Swift

    @MainActor
    open lazy var contentView: UIView { get set }
  • 图片视图,仅Image生效

    Declaration

    Swift

    @MainActor
    open lazy var imageView: UIImageView { get set }
  • 指示器视图,可自定义,仅Indicator生效

    Declaration

    Swift

    @MainActor
    open lazy var indicatorView: UIView & IndicatorViewPlugin { get set }
  • 进度条视图,可自定义,仅Progress生效

    Declaration

    Swift

    @MainActor
    open lazy var progressView: UIView & ProgressViewPlugin { get set }
  • 标题标签,都存在,有内容时才显示

    Declaration

    Swift

    @MainActor
    open lazy var titleLabel: UILabel { get set }
  • 消息标签,都存在,有内容时才显示

    Declaration

    Swift

    @MainActor
    open lazy var messageLabel: UILabel { get set }

Lifecycle

  • 初始化指定类型指示器

    Declaration

    Swift

    @MainActor
    public init(type: ToastViewType)
  • 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 layoutSubviews()
  • Undocumented

    Declaration

    Swift

    @MainActor
    override open func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView?

Public

  • 获取内容视图尺寸,需bounds存在时才有值

    Declaration

    Swift

    @MainActor
    open var contentViewSize: CGSize { get }
  • 显示吐司,不执行动画

    Declaration

    Swift

    @MainActor
    open func show()
  • 显示吐司,执行淡入渐变动画

    Declaration

    Swift

    @MainActor
    open func show(animated: Bool)
  • 隐藏吐司。吐司不存在时返回NO

    Declaration

    Swift

    @discardableResult
    @MainActor
    open func hide() -> Bool
  • 隐藏吐司,延迟指定时间后执行。吐司不存在时返回NO

    Declaration

    Swift

    @discardableResult
    @MainActor
    open func hide(afterDelay delay: TimeInterval, completion: (@MainActor @Sendable () -> Void)? = nil) -> Bool
  • 清理延迟隐藏吐司定时器

    Declaration

    Swift

    @MainActor
    open func invalidateTimer()