type
status
date
slug
summary
tags
category
icon
password
1、重写 point(inside point: CGPoint, with event: UIEvent?) 方法
不推荐在 extension 中重写该方法,extension 的初衷是去扩展一个类,而不是去改变一个类
如果是个圆形:
2、重写 hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView?
同理,不推荐在 UIButton 的 extension 中实现该方法
如果是个圆形 (touchPointInsideCircle 方法在 (1) 中)
3、method swizzling 交换以上两个方法,不推荐
- 作者:NotionNext
- 链接:https://tangly1024.com/article/UIButton%20%E6%89%A9%E5%A4%A7%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6%E7%9A%84%E4%B8%89%E7%A7%8D%E6%96%B9%E5%BC%8F
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章