swift的代码教程-ios警告框类(VKAlert)

随意总结下,ios的几种警告框,学习使用。谢谢勿喷!

  1. import Foundation  
  2. import UIkit  
  3. class VKAlert:NSObject{  
  4.     class func commonAlert(title:String!,message:String!,okButton:String!,cancleButton:String!,delegate:AnyObject!)->UIAlertView{  
  5.         var alert = UIAlertView()  
  6.         alert.title = title  
  7.         alert.message = message  
  8.         alert.delegate = delegate  
  9.         alert.addButtonWithTitle(cancleButton)  
  10.         alert.addButtonWithTitle(okButton)  
  11.         alert.show()  
  12.         return alert  
  13.     }  
  14.       
  15.     class func loginAlert(title:String!,message:String!,okButton:String!,cancleButton:String!,delegate:AnyObject!)->UIAlertView{  
  16.         var alert = UIAlertView()  
  17.         alert.title = title  
  18.         alert.message = message  
  19.         alert.delegate = delegate  
  20.         alert.addButtonWithTitle(cancleButton)  
  21.         alert.addButtonWithTitle(okButton)  
  22.           
  23.         alert.alertViewStyle = UIAlertViewStyle.LoginAndPasswordInput  
  24.         alert.show()  
  25.         return alert  
  26.     }  
  27.       
  28.     class func intputAlert(title:String!,message:String!,okButton:String!,cancleButton:String!,delegate:AnyObject!)->UIAlertView{  
  29.         var alert = UIAlertView()  
  30.         alert.title = title  
  31.         alert.message = message  
  32.         alert.delegate = delegate  
  33.         alert.addButtonWithTitle(cancleButton)  
  34.         alert.addButtonWithTitle(okButton)  
  35.         alert.alertViewStyle = UIAlertViewStyle.PlainTextInput  
  36.         alert.show()  
  37.         return alert  
  38.     }  
  39.       
  40.     class func lodingAlert(title:String!)->UIAlertView{  
  41.          var alert = UIAlertView()  
  42.          alert.title = title  
  43.          alert.show()  
  44.          var activeView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.White)  
  45.          activeView.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 40)  
  46.          activeView.startAnimating()  
  47.          alert.addSubview(activeView)  
  48.         return alert   
  49.     }  
  50.       
  51.     class func cancleAlert(alert:UIAlertView!){  
  52.         if alert {  
  53.             alert.dismissWithClickedButtonIndex(0, animated: false)  
  54.         }  
  55.           
  56.     }  
  57. }  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值