class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//手势识别器
//UIGestureRecognizer
//识别在某一个视图上的操作
let tap = UITapGestureRecognizer(target: self, action: #selector(didTap(_:)))
self.view.addGestureRecognizer(tap)
}
func didTap(sender: UITapGestureRecognizer) {
//返回参考self.view的坐标
let location = sender.locationInView(self.view)
print("tap: \(location)")
//UIAlertView + UIActionSheet
let alertCtrl = UIAlertController(title: "警告", message: "不要乱点", preferredStyle: .ActionSheet)
let action01 = UIAlertAction(title: "OK", style: .Default) { (action) in
print("OK")
}
let action02 = UIAlertAction(title: "Cancel", style: .Destructive) { (action) in
print("Cancel")
}
let action03 = UIAlertAction(title: "3", style: .Default) { (action) in
print("3")
}
alertCtrl.addAction(action01)
alertCtrl.addAction(action02)
alertCtrl.addAction(action03)
self.presentViewController(alertCtrl, animated: true, completion: nil)
}
}
PKHUD
func didTap(sender: UITapGestureRecognizer){
let url = NSURL(string: "https://github.com")
let task = NSURLSession.sharedSession().dataTaskWithURL(url!) { (data, response, error) in
dispatch_async(dispatch_get_main_queue(), {
HUD.hide()
HUD.flash(.Success, delay: 2, completion: nil)
})
}
task.resume()
HUD.show(.SystemActivity)
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。