QMUIDialogViewController

弹窗组件基类,自带headerViewcontentViewfooterView,并通过addCancelButtonWithText:block:addSubmitButtonWithText:block:方法来添加取消、确定按钮。 建议将一个自定义的UIView设置给contentView属性,此时弹窗将会自动帮你计算大小并布局。大小取决于你的contentView的sizeThatFits:返回值。 弹窗继承自QMUICommonViewController,因此可直接使用self.titleView的功能来实现双行标题,具体请查看QMUINavigationTitleViewQMUIDialogViewController支持以类似UIAppearance的方式来统一设置全局的dialog样式,例如[QMUIDialogViewController appearance].headerViewHeight = 48;

See

QMUIDialogSelectionViewController

See

QMUIDialogTextFieldViewController
  • Undocumented

    Declaration

    Objective-C

    @property(nonatomic, assign) CGFloat        cornerRadius

    Swift

    var cornerRadius: CGFloat { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nonatomic, assign) UIEdgeInsets   dialogViewMargins

    Swift

    var dialogViewMargins: UIEdgeInsets { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nonatomic, assign) CGFloat        maximumContentViewWidth

    Swift

    var maximumContentViewWidth: CGFloat { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIColor        *backgroundColor

    Swift

    var backgroundColor: UIColor? { get set }
  • 标题的 tintColor,当没有设置 titleLabelTextColor 和 subTitleLabelTextColor 的情况下,标题和副标题的颜色均会使用 titleTintColor,当 titleLabelTextColor 和 subTitleLabelTextColor 其中任何一个被设置了值时,则 titleTintColor 作为候选项使用(也即谁为 nil 才会用 titleTintColor 顶替,不为 nil 则不会用到 titleTintColor)。 默认为 nil

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) UIColor *titleTintColor;

    Swift

    var titleTintColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIFont         *titleLabelFont

    Swift

    var titleLabelFont: UIFont? { get set }
  • 主标题的文字颜色,当为 nil 时则会使用 titleView 的 tintColor 作为文字颜色

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) UIColor *titleLabelTextColor;

    Swift

    var titleLabelTextColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIFont         *subTitleLabelFont

    Swift

    var subTitleLabelFont: UIFont? { get set }
  • 副标题的文字颜色,当为 nil 时则会使用 titleView 的 tintColor 作为文字颜色

    Note

    副标题可通过 dialog.titleView.subtitle 来设置

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) UIColor *subTitleLabelTextColor;

    Swift

    var subTitleLabelTextColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIColor        *headerSeparatorColor

    Swift

    var headerSeparatorColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nonatomic, assign) CGFloat        headerViewHeight

    Swift

    var headerViewHeight: CGFloat { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIColor        *headerViewBackgroundColor

    Swift

    var headerViewBackgroundColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nonatomic, assign) UIEdgeInsets   contentViewMargins

    Swift

    var contentViewMargins: UIEdgeInsets { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIColor        *contentViewBackgroundColor

    Swift

    var contentViewBackgroundColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIColor        *footerSeparatorColor

    Swift

    var footerSeparatorColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nonatomic, assign) CGFloat        footerViewHeight

    Swift

    var footerViewHeight: CGFloat { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIColor        *footerViewBackgroundColor

    Swift

    var footerViewBackgroundColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIColor        *buttonBackgroundColor

    Swift

    var buttonBackgroundColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong) UIColor        *buttonHighlightedBackgroundColor

    Swift

    var buttonHighlightedBackgroundColor: UIColor? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, copy) NSDictionary<NSAttributedStringKey, id> *buttonTitleAttributes

    Swift

    var buttonTitleAttributes: [NSAttributedString.Key : Any]? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong, readonly) UIView *headerView

    Swift

    var headerView: UIView? { get }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong, readonly) CALayer *headerViewSeparatorLayer

    Swift

    var headerViewSeparatorLayer: CALayer? { get }
  • dialog的主体内容部分,默认是一个空的白色UIView,建议设置为自己的UIView dialog会通过询问contentView的sizeThatFits得到当前内容的大小

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) UIView *contentView;

    Swift

    var contentView: UIView? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong, readonly) UIView *footerView

    Swift

    var footerView: UIView? { get }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong, readonly) CALayer *footerViewSeparatorLayer

    Swift

    var footerViewSeparatorLayer: CALayer? { get }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong, readonly) QMUIButton *cancelButton

    Swift

    var cancelButton: QMUIButton? { get }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong, readonly) QMUIButton *submitButton

    Swift

    var submitButton: QMUIButton? { get }
  • Undocumented

    Declaration

    Objective-C

    @property(nullable, nonatomic, strong, readonly) CALayer *buttonSeparatorLayer

    Swift

    var buttonSeparatorLayer: CALayer? { get }
  • 添加位于左下角的取消按钮,取消按钮点击时默认会自动 hide 弹窗,无需自己在 block 里调用 hide。

    同一时间只能存在一个取消按钮,所以每次添加都会移除上一个取消按钮。

    Declaration

    Objective-C

    - (void)addCancelButtonWithText:(nonnull NSString *)buttonText
                              block:
                                  (void (^_Nullable)(
                                      __kindof QMUIDialogViewController *_Nonnull))
                                      block;

    Swift

    func addCancelButton(withText buttonText: String, block: ((QMUIDialogViewController) -> Void)? = nil)

    Parameters

    buttonText

    按钮文字

    block

    按钮点击后的事件。取消按钮会自动 hide 弹窗,无需在 block 里调用 hide

  • 移除当前的取消按钮

    Declaration

    Objective-C

    - (void)removeCancelButton;

    Swift

    func removeCancelButton()
  • 添加位于右下角的提交按钮

    同一时间只能存在一个提交按钮,所以每次添加都会移除上一个提交按钮

    Declaration

    Objective-C

    - (void)addSubmitButtonWithText:(nonnull NSString *)buttonText
                              block:
                                  (void (^_Nullable)(
                                      __kindof QMUIDialogViewController *_Nonnull))
                                      block;

    Swift

    func addSubmitButton(withText buttonText: String, block: ((QMUIDialogViewController) -> Void)? = nil)

    Parameters

    buttonText

    按钮文字

    block

    按钮点击后的事件,如果需要在点击后关闭浮层,需要在 block 里自行调用 hide

  • 移除提交按钮

    Declaration

    Objective-C

    - (void)removeSubmitButton;

    Swift

    func removeSubmitButton()
  • 用于展示 dialog 的 modalPresentationViewController

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) QMUIModalPresentationViewController *modalPresentationViewController;

    Swift

    var modalPresentationViewController: QMUIModalPresentationViewController? { get set }
  • 以动画形式显示弹窗,等同于 [self showWithAnimated:YES completion:nil]

    Declaration

    Objective-C

    - (void)show;

    Swift

    func show()
  • 显示弹窗

    Declaration

    Objective-C

    - (void)showWithAnimated:(BOOL)animated
                  completion:(void (^_Nullable)(BOOL))completion;

    Swift

    func showWith(animated: Bool, completion: ((Bool) -> Void)? = nil)

    Parameters

    animated

    是否用动画的形式

    completion

    弹窗显示出来后的回调

  • 以动画形式隐藏弹窗,等同于 [self hideWithAnimated:YES completion:nil]

    Declaration

    Objective-C

    - (void)hide;

    Swift

    func hide()
  • 隐藏弹窗

    Declaration

    Objective-C

    - (void)hideWithAnimated:(BOOL)animated
                  completion:(void (^_Nullable)(BOOL))completion;

    Swift

    func hideWith(animated: Bool, completion: ((Bool) -> Void)? = nil)

    Parameters

    animated

    是否用动画的形式

    completion

    弹窗隐藏后的回调

UIAppearance

  • Undocumented

    Declaration

    Objective-C

    + (instancetype)appearance;

    Swift

    class func appearance() -> Self