前言ide
一开始还觉得代码写的有问题,点击事件里面有比较耗时卡主线程的代码,逐一删减代码发现并非这么回事。spa
声明
欢迎转载,但请保留文章原始出处:)
博客园:http://www.cnblogs.com
农民伯伯: http://over140.cnblogs.com.net
正文线程
和参考文章里说的状况不彻底相同,UIButton 并无放在 UIScrollView 或 UITableView 上,可是 ViewController 是支持滑动返回的。 code
——————————————————华丽的分割线,搜索猜想解题中————————————————————————blog
解决办法:也没什么好办法,换成 ImageView 加 UITapGestureRecognizer 吧,另外奉上点击效果代码 :) 事件
class UIImageViewEffect : UIImageView { var effectAlpha: CGFloat = 0.5 override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { alpha = effectAlpha } override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) { self.alpha = 1 } override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { self.alpha = 1 } }
参考get