准备边学swift边完善这个项目,进度可能有一点慢。如果对你有一定的帮助求❤️star
1 class DRAlert: UIView { 2 3 @IBOutlet weak var titleLabel: UILabel! 4 @IBOutlet weak var messLabel: UILabel! 5 @IBOutlet weak var layoutC1: NSLayoutConstraint! 6 @IBOutlet weak var layoutC2: NSLayoutConstraint! 7 8 private var cancelBlock: (() -> ()) = {}; 9 private var confirmBlock: (() -> ()) = {}; 10 11 override func awakeFromNib() { 12 super.awakeFromNib(); 13 self.layoutC1.constant = 0.5; 14 self.layoutC2.constant = 0.5; 15 self.frame = UIScreen.mainScreen().bounds; 16 self.autoresizingMask = UIViewAutoresizing.None; 17 } 18 19 internal class func alert(title: String?, mess: String?, cancelBlock: (() -> ()), confirmBlock: (() -> ())) -> (DRAlert) { 20 let alert = NSBundle.mainBundle().loadNibNamed("DRAlert", owner: nil, options: nil).first as! DRAlert; 21 alert.titleLabel.text = title; 22 alert.messLabel.text = mess; 23 alert.cancelBlock = cancelBlock; 24 alert.confirmBlock = confirmBlock; 25 return alert; 26 } 27 28 internal func show() -> () { 29 UIApplication.sharedApplication().keyWindow?.addSubview(self); 30 } 31 32 internal func diss() -> () { 33 self.removeFromSuperview(); 34 } 35 36 @IBAction func cancelButtonClick() { 37 self.diss(); 38 self.cancelBlock(); 39 } 40 41 @IBAction func confirmButtonClick() { 42 self.diss(); 43 self.confirmBlock(); 44 } 45 }
2.1、主页
2.2、控制台
2.3、域名注册