IOS 解决UIButton 点击卡顿/延迟的问题
前言
一开始还以为代码写的有问题,点击事件里面有比较耗时卡主线程的代码,逐一删减代码发现并不是这么回事。
正文
和参考文章里说的情况不完全相同,UIButton并没有放在UIScrollView或UITableView上,但是ViewController是支持滑动返回的。
——————————————————华丽的分割线,搜索猜测解题中——————————————————
解决办法:也没什么好办法,换成ImageView加UITapGestureRecognizer吧,另外奉上点击效果代码:)
classUIImageViewEffect:UIImageView{
vareffectAlpha:CGFloat=0.5
overridefunctouchesBegan(touches:Set<UITouch>,withEventevent:UIEvent?){
alpha=effectAlpha
}
overridefunctouchesCancelled(touches:Set<UITouch>?,withEventevent:UIEvent?){
self.alpha=1
}
overridefunctouchesEnded(touches:Set<UITouch>,withEventevent:UIEvent?){
self.alpha=1
}
}
以上就是解决IOSUIButton出现卡顿的问题,有需要的朋友参考下。