let alert =AlertView(title:"This is title", subTitle:"This is subTitle", detail:"This is detail", subDetail:"This is subDetail")let action1 =AlertAction(type:.none){
alert.dismiss()}
action1.title ="This is action1"let action2 =AlertAction(type:.none){
alert.dismiss()}
action2.title ="This is action2"
alert.addAction(alertAction: action1)
alert.addAction(alertAction: action2)
alert.show()
效果:
代码
importUIKitimportSnapKitenumAlertActionType{
casenone;case done;case error;case cancel;}classAlertAction:NSObject{
var type:AlertActionType=.nonevar complete:(()->Void)?var title:String?init(type:AlertActionType, complete:(()->())?=nil){
self.type = type
self.complete = complete
super.init()}}classAlertView:UIView{
let titleView:UILabel={
let view =UILabel()
view.font =UIFont.pf_semibold(16)
view.textAlignment =.center
view.numberOfLines =0
view.textColor =UIColor(red:0.2, green:0.2, blue:0.2, alpha:1)return view
}()let subTitleView:UILabel={
let view =UILabel()
view.font =UIFont.pf_semibold(16)
view.textAlignment =.center
view.numberOfLines =0
view.textColor =.black
return view
}()let detailView:UILabel={
let view =UILabel()
view.font =UIFont.pf_medium(16)
view.textAlignment <