AlertController
@MainActor
open class AlertController : UIViewController, UIViewControllerTransitioningDelegate
自定义弹窗控制器
-
获取所有动作
Declaration
Swift
@MainActor open private(set) var actions: [AlertAction] { get }
-
设置首选动作
Declaration
Swift
@MainActor open var preferredAction: AlertAction? { get set }
-
获取所有输入框
Declaration
Swift
@MainActor open private(set) var textFields: [UITextField]? { get }
-
主标题
Declaration
Swift
@MainActor override open var title: String? { get set }
-
副标题
Declaration
Swift
@MainActor open var message: String? { get set }
-
弹窗样式,默认Default
Declaration
Swift
@MainActor open var alertStyle: AlertStyle
-
动画类型
Declaration
Swift
@MainActor open var animationType: AlertAnimationType { get set }
-
主标题(富文本)
Declaration
Swift
@MainActor open var attributedTitle: NSAttributedString? { get set }
-
副标题(富文本)
Declaration
Swift
@MainActor open var attributedMessage: NSAttributedString? { get set }
-
头部图标,位置处于title之上,大小取决于图片本身大小
Declaration
Swift
@MainActor open var image: UIImage? { get set }
-
主标题颜色
Declaration
Swift
@MainActor open var titleColor: UIColor? { get set }
-
主标题字体,默认18,加粗
Declaration
Swift
@MainActor open var titleFont: UIFont? { get set }
-
副标题颜色
Declaration
Swift
@MainActor open var messageColor: UIColor? { get set }
-
副标题字体,默认16,未加粗
Declaration
Swift
@MainActor open var messageFont: UIFont? { get set }
-
对齐方式(包括主标题和副标题)
Declaration
Swift
@MainActor open var textAlignment: NSTextAlignment { get set }
-
头部图标的限制大小,默认无穷大
Declaration
Swift
@MainActor open var imageLimitSize: CGSize { get set }
-
图片的tintColor,当外部的图片使用了AlwaysTemplate的渲染模式时,该属性可起到作用
Declaration
Swift
@MainActor open var imageTintColor: UIColor? { get set }
-
action水平排列还是垂直排列 actionSheet样式下:默认为UILayoutConstraintAxisVertical(垂直排列), 如果设置为UILayoutConstraintAxisHorizontal(水平排列),则除去取消样式action之外的其余action将水平排列 alert样式下:当actions的个数大于2,或者某个action的title显示不全时为UILayoutConstraintAxisVertical(垂直排列),否则默认为UILayoutConstraintAxisHorizontal(水平排列),此样式下设置该属性可以修改所有action的排列方式 不论哪种样式,只要外界设置了该属性,永远以外界设置的优先
Declaration
Swift
@MainActor open var actionAxis: NSLayoutConstraint.Axis { get set }
-
距离屏幕边缘的最小间距 alert样式下该属性是指对话框四边与屏幕边缘之间的距离,此样式下默认值随设备变化,actionSheet样式下是指弹出边的对立边与屏幕之间的距离,比如如果从右边弹出,那么该属性指的就是对话框左边与屏幕之间的距离,此样式下默认值为70
Declaration
Swift
@MainActor open var minDistanceToEdges: CGFloat { get set }
-
Alert样式下默认6.0f,ActionSheet样式下默认13.0f,去除半径设置为0即可
Declaration
Swift
@MainActor open var cornerRadius: CGFloat { get set }
-
对话框的偏移量,y值为正向下偏移,为负向上偏移;x值为正向右偏移,为负向左偏移,该属性只对Alert样式有效,键盘的frame改变会自动偏移,如果手动设置偏移只会取手动设置的
Declaration
Swift
@MainActor open var offsetForAlert: CGPoint { get set }
-
是否需要对话框拥有毛玻璃,默认为NO
Declaration
Swift
@MainActor open var needDialogBlur: Bool { get set }
-
是否含有自定义TextField,键盘的frame改变会自动偏移,默认为NO
Declaration
Swift
@MainActor open var hasCustomTextField: Bool
-
是否单击背景退出对话框,默认为YES
Declaration
Swift
@MainActor open var tapBackgroundViewDismiss: Bool
-
是否点击动作按钮退出动画框,默认为YES
Declaration
Swift
@MainActor open var tapActionDismiss: Bool
-
单击背景dismiss完成回调,默认nil
Declaration
Swift
@MainActor open var dismissCompletion: (() -> Void)?
-
事件代理
Declaration
Swift
@MainActor open weak var delegate: AlertControllerDelegate?
-
弹出框样式
Declaration
Swift
@MainActor open private(set) var preferredStyle: AlertControllerStyle { get }
-
自定义样式,默认为样式单例
Declaration
Swift
@MainActor open var alertAppearance: AlertControllerAppearance { get }
-
创建控制器(默认对话框)
Declaration
Swift
@MainActor public convenience init(title: String?, message: String?, preferredStyle: AlertControllerStyle, animationType: AlertAnimationType = .default, appearance: AlertControllerAppearance? = nil)
-
创建控制器(自定义整个对话框)
Declaration
Swift
@MainActor public convenience init(customAlertView: UIView, preferredStyle: AlertControllerStyle, animationType: AlertAnimationType = .default, appearance: AlertControllerAppearance? = nil)
-
创建控制器(自定义对话框的头部)
Declaration
Swift
@MainActor public convenience init(customHeaderView: UIView, preferredStyle: AlertControllerStyle, animationType: AlertAnimationType = .default, appearance: AlertControllerAppearance? = nil)
-
创建控制器(自定义对话框的action部分)
Declaration
Swift
@MainActor public convenience init(customActionSequenceView: UIView, title: String?, message: String?, preferredStyle: AlertControllerStyle, animationType: AlertAnimationType = .default, appearance: AlertControllerAppearance? = nil)
-
Undocumented
Declaration
Swift
@MainActor override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?)
-
Undocumented
Declaration
Swift
@MainActor public required init?(coder: NSCoder)
-
Undocumented
Declaration
Swift
@MainActor override open func loadView()
-
Undocumented
Declaration
Swift
@MainActor override open func viewDidLoad()
-
Undocumented
Declaration
Swift
@MainActor override open func viewWillAppear(_ animated: Bool)
-
Undocumented
Declaration
Swift
@MainActor override open func viewWillLayoutSubviews()
-
Undocumented
Declaration
Swift
@MainActor override open func viewDidLayoutSubviews()
-
添加动作
Declaration
Swift
@MainActor open func addAction(_ action: AlertAction)
-
添加文本输入框,一旦添加后就会仅回调一次configurationHandler
Declaration
Swift
@MainActor open func addTextField(configurationHandler: (@MainActor @Sendable (UITextField) -> Void)? = nil)
-
设置alert样式下的偏移量,动画为NO则跟属性offsetForAlert等效
Declaration
Swift
@MainActor open func setOffsetForAlert(_ offsetForAlert: CGPoint, animated: Bool)
-
设置action与下一个action之间的间距, action仅限于非取消样式,必须在‘-addAction:'之后设置,nil时设置header与action间距
Declaration
Swift
@MainActor open func setCustomSpacing(_ spacing: CGFloat, afterAction action: AlertAction?)
-
获取action与下一个action之间的间距, action仅限于非取消样式,必须在‘-addAction:'之后获取,nil时获取header与action间距
Declaration
Swift
@MainActor open func customSpacingAfterAction(_ action: AlertAction?) -> CGFloat
-
设置蒙层的外观样式,可通过alpha调整透明度
Declaration
Swift
@MainActor open func setBackgroundViewAppearanceStyle(_ style: UIBlurEffect.Style?, alpha: CGFloat)
-
插入一个组件view,位置处于头部和action部分之间,要求头部和action部分同时存在
Declaration
Swift
@MainActor open func insertComponentView(_ componentView: UIView)
-
更新自定义view的size,比如屏幕旋转,自定义view的大小发生了改变,可通过该方法更新size
Declaration
Swift
@MainActor open func updateCustomViewSize(_ size: CGSize)
-
Undocumented
Declaration
Swift
@MainActor open func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
-
Undocumented
Declaration
Swift
@MainActor open func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
-
Undocumented
Declaration
Swift
@MainActor open func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?