UIView重叠点击透过上层UIView

今天由于需求问题需要UIView的部分区域透过点击到下一层UIView所以搜索了一下资料发现只要重写pointInside就可以实现,swift代码如下
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool
{
let frame = aFrame // aFrame是指不能透过的view的frame这其实是根据需求来的,你也可以做透过的判断
if frame?.contains(point) ?? false
{
return true
}
else
{
return false
}
}

0 0 vote
Article Rating
Subscribe
提醒
guest
0 评论
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x