PlaceholderView

@MainActor
open class PlaceholderView : UIView

通用的空界面控件,布局顺序从上到下依次为:imageView, loadingView, textLabel, detailTextLabel, actionButton

QMUI_iOS

Accessor

  • 内容视图间距,默认为(0, 16, 0, 16)

    Declaration

    Swift

    @MainActor
    open var contentViewInsets: UIEdgeInsets { get set }
  • 图片视图间距,默认为(0, 0, 36, 0)

    Declaration

    Swift

    @MainActor
    open var imageViewInsets: UIEdgeInsets { get set }
  • 加载视图间距,默认为(0, 0, 36, 0)

    Declaration

    Swift

    @MainActor
    open var loadingViewInsets: UIEdgeInsets { get set }
  • 文本视图间距,默认为(0, 0, 10, 0)

    Declaration

    Swift

    @MainActor
    open var textLabelInsets: UIEdgeInsets { get set }
  • 详细文本视图间距,默认为(0, 0, 14, 0)

    Declaration

    Swift

    @MainActor
    open var detailTextLabelInsets: UIEdgeInsets { get set }
  • 动作按钮间距,默认为(0, 0, 0, 0)

    Declaration

    Swift

    @MainActor
    open var actionButtonInsets: UIEdgeInsets { get set }
  • 更多动作按钮间距,默认为(0, 24, 0, 0)

    Declaration

    Swift

    @MainActor
    open var moreActionButtonInsets: UIEdgeInsets { get set }
  • 如果不想要内容整体垂直居中,则可通过调整此属性来进行垂直偏移。默认为-30,即内容比中间略微偏上

    Declaration

    Swift

    @MainActor
    open var verticalOffset: CGFloat { get set }
  • 自定义垂直偏移句柄,参数依次为总高度,内容高度,图片高度

    Declaration

    Swift

    @MainActor
    open var verticalOffsetBlock: ((_ totalHeight: CGFloat, _ contentHeight: CGFloat, _ imageHeight: CGFloat) -> CGFloat)? { get set }
  • textLabel字体,默认为15pt系统字体

    Declaration

    Swift

    @MainActor
    open var textLabelFont: UIFont { get set }
  • detailTextLabel字体,默认为14pt系统字体

    Declaration

    Swift

    @MainActor
    open var detailTextLabelFont: UIFont { get set }
  • actionButton标题字体,默认为15pt系统字体

    Declaration

    Swift

    @MainActor
    open var actionButtonFont: UIFont { get set }
  • moreActionButton标题字体,默认为15pt系统字体

    Declaration

    Swift

    @MainActor
    open var moreActionButtonFont: UIFont { get set }
  • loadingView颜色,默认nil为指示器颜色

    Declaration

    Swift

    @MainActor
    open var loadingViewColor: UIColor? { get set }
  • textLabel文本颜色,默认为(93, 100, 110)

    Declaration

    Swift

    @MainActor
    open var textLabelTextColor: UIColor { get set }
  • detailTextLabel文本颜色,默认为(133, 140, 150)

    Declaration

    Swift

    @MainActor
    open var detailTextLabelTextColor: UIColor { get set }
  • actionButton标题颜色,默认为(49, 189, 243)

    Declaration

    Swift

    @MainActor
    open var actionButtonTitleColor: UIColor { get set }
  • moreActionButton标题颜色,默认为(49, 189, 243)

    Declaration

    Swift

    @MainActor
    open var moreActionButtonTitleColor: UIColor { get set }

Subviews

  • 如果要继承PlaceholderView并添加新的子 view,则必须:

    1. 像其它自带 view 一样添加到 contentView 上
    2. 重写sizeThatContentViewFits

    Declaration

    Swift

    @MainActor
    open lazy var contentView: UIView { get set }
  • 此控件通过设置 loadingView.hidden 来控制 loadinView 的显示和隐藏,因此请确保你的loadingView 没有类似于 hidesWhenStopped = YES 之类会使 view.hidden 失效的属性

    Declaration

    Swift

    @MainActor
    open lazy var loadingView: UIView & IndicatorViewPlugin { get set }
  • 图片控件

    Declaration

    Swift

    @MainActor
    open lazy var imageView: UIImageView { get set }
  • 文本控件

    Declaration

    Swift

    @MainActor
    open lazy var textLabel: UILabel { get set }
  • 详细文本控件

    Declaration

    Swift

    @MainActor
    open lazy var detailTextLabel: UILabel { get set }
  • 动作按钮控件

    Declaration

    Swift

    @MainActor
    open lazy var actionButton: UIButton { get set }
  • 更多动作按钮控件,默认隐藏

    Declaration

    Swift

    @MainActor
    open lazy var moreActionButton: UIButton { get set }

Lifecycle

  • 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()

Public

  • 显示或隐藏loading图标

    Declaration

    Swift

    @MainActor
    open func setLoadingViewHidden(_ hidden: Bool)
  • 设置要显示的图片 @param image 要显示的图片,为nil则不显示

    Declaration

    Swift

    @MainActor
    open func setImage(_ image: UIImage?)
  • 设置提示语 @param text 提示语文本,若为nil则隐藏textLabel

    Declaration

    Swift

    @MainActor
    open func setTextLabelText(_ text: String?)
  • 设置提示语 @param text 提示语文本,若为nil则隐藏textLabel

    Declaration

    Swift

    @MainActor
    open func setTextLabelText(_ text: NSAttributedString?)
  • 设置详细提示语的文本 @param text 详细提示语文本,若为nil则隐藏detailTextLabel

    Declaration

    Swift

    @MainActor
    open func setDetailTextLabelText(_ text: String?)
  • 设置详细提示语的文本 @param text 详细提示语文本,若为nil则隐藏detailTextLabel

    Declaration

    Swift

    @MainActor
    open func setDetailTextLabelText(_ text: NSAttributedString?)
  • 设置操作按钮的文本 @param title 操作按钮的文本,若为nil则隐藏actionButton

    Declaration

    Swift

    @MainActor
    open func setActionButtonTitle(_ title: String?)
  • 设置操作按钮的文本 @param title 操作按钮的文本,若为nil则隐藏actionButton

    Declaration

    Swift

    @MainActor
    open func setActionButtonTitle(_ title: NSAttributedString?)
  • 设置更多操作按钮的文本 @param title 操作按钮的文本,若为nil则隐藏moreActionButton

    Declaration

    Swift

    @MainActor
    open func setMoreActionButtonTitle(_ title: String?)
  • 设置更多操作按钮的文本 @param title 操作按钮的文本,若为nil则隐藏moreActionButton

    Declaration

    Swift

    @MainActor
    open func setMoreActionButtonTitle(_ title: NSAttributedString?)
  • 返回一个恰好容纳所有子 view 的大小

    Declaration

    Swift

    @MainActor
    open func sizeThatContentViewFits() -> CGSize