gpt4 book ai didi

UIView:如何检查触摸是否在它们开始的同一 View 内结束

转载 作者:行者123 更新时间:2023-12-04 08:15:35 25 4
gpt4 key购买 nike

AcaniUsers ,我创建了一个网格 ThumbView : UIView UITableView 内的实例.全部 thumbViews宽度为 kThumbSize .如何检测触摸是否在它们开始的同一 View 内结束?

最佳答案

在您使用的 View 扩展中;

swift 4:

open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
guard let touchPoint = touches.first?.location(in: self) else { return }
guard self.bounds.contains(touchPoint) else { return }
// Do items for successful touch inside the view
}

关于UIView:如何检查触摸是否在它们开始的同一 View 内结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5761782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com