扫码关注官方订阅号
UIView可不可以设置相应事件范围。比如一个正方向的view,我想让它左边部分响应事件。右边部分不响应事件,但可以把事件传递给后面的responder去响应。
光阴似箭催人老,日月如移越少年。
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event; - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event;
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { CGRect rect = CGRectMake(0, 0, self.view.bounds.size.width/2, self.view.bounds.size.height); if (CGRectContainsPoint(rect, point)) return [super hitText:point withEvent:event]; else return nil; }
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
光阴似箭催人老,日月如移越少年。