我有一个自定义标签栏,该标签栏禁止在特定位置单击”>
class UserTabBar: BaseTabBar { override func draw(_ rect: CGRect) { super.addShape(for: .user) } override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { let buttonRadius: CGFloat = 35 return abs(self.center.x - point.x) > buttonRadius || abs(point.y) > buttonRadius } }
但是在由标签栏包裹的控制器中,有一个tableview,并且滚动不起作用我如何只能将其限制在标签栏的框架内:
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
let buttonRadius: CGFloat = 35
return abs(self.center.x - point.x) > buttonRadius || abs(point.y) > buttonRadius
}
我有一个自定义标签栏,我禁止在特定的位置类中单击。UserTabBar:BaseTabBar {重写func draw(_ rect:CGRect){super.addShape(for:.user)}重写func ...
我使用以下方法解决了我的问题:
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
guard !clipsToBounds && !isHidden && alpha > 0, path.contains(point) else { return nil }
for member in subviews.reversed() {
let subPoint = member.convert(point, from: self)
guard let result = member.hitTest(subPoint, with: event) else { continue }
return result
}
return nil
}