LEEAlert--iOS自定义警告框

前言:

作为一个iOS开发(bugMaker,哈哈),最常见的就是系统的警告框,但是在iOS 9之后,没有aletView.show()这个方法了,这是不是很蛋疼,并不想用当前的控制器推出一个警告控制器,所以,LEEAlert是你替代绝佳的选择

iOS 9之前使用方法:

1.系统的alert:

    let alertView = UIAlertView(title: "系统警告框", message: "这是系统原生的警告框", delegate: nil, cancelButtonTitle: "cancle", otherButtonTitles: "OK")
    alertView.show()

2.系统的actionSheet:

    let sheet = UIActionSheet(title: "系统选项框", delegate: nil, cancelButtonTitle: "cancle", destructiveButtonTitle: "delegate")
    sheet.show(in: self.view)

iOS 9之后的使用方法:

1.系统的alert:

    let alert = UIAlertController(title: "系统警告框", message: "这是系统原生的警告框", preferredStyle: .alert)
    let done = UIAlertAction(title: "OK", style: .default) { (action) in
        
    }
    let cancle = UIAlertAction(title: "cancle", style: .cancel) { (action) in
        
    }
    alert.addAction(done)
    alert.addAction(cancle)
    self.present(alert, animated: true, completion: nil)

2.系统的actionSheet:

    let alert = UIAlertController(title: "系统警告框", message: "这是系统原生的警告框", preferredStyle: .actionSheet)
    let done = UIAlertAction(title: "OK", style: .default) { (action) in
        
    }
    let cancle = UIAlertAction(title: "cancle", style: .cancel) { (action) in
        
    }
    alert.addAction(done)
    alert.addAction(cancle)
    self.present(alert, animated: true, completion: nil)

LEEAlert使用方法:

alert

    let _ = LEEAlert.alert().config.leeTitle("LEEAlert警告框")?.leeContent("这是LEEAlert警告框")?.leeAddAction({action in
            action?.title = "cancle"
        })?.leeAddAction({action in
            action?.title = "OK"
        })?.leeShow()

actionSheet

    let _ = LEEAlert.actionsheet().config.leeTitle("LEEAlert选项框")?.leeContent("这是LEEAlert选项框")?.leeAddAction({action in
            action?.title = "cancle"
        })?.leeAddAction({action in
            action?.title = "OK"
        })?.leeShow()

你可能感兴趣的:(LEEAlert--iOS自定义警告框)