美文网首页
iOS button过小点击不灵敏解决方案

iOS button过小点击不灵敏解决方案

作者: 翻滚的炒勺2013 | 来源:发表于2017-07-08 10:37 被阅读104次

重写- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent*)event

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent*)event
{
    CGRect bounds = self.bounds;
    //若原热区小于44x44,则放大热区,否则保持原大小不变
    CGFloat widthDelta = MAX(44.0 - bounds.size.width, 0);
    CGFloat heightDelta = MAX(44.0 - bounds.size.height, 0);
    bounds = CGRectInset(bounds, -0.5 * widthDelta, -0.5 * heightDelta);
    return CGRectContainsPoint(bounds, point);
}

相关文章

网友评论

      本文标题:iOS button过小点击不灵敏解决方案

      本文链接:https://www.haomeiwen.com/subject/ybmdhxtx.html