iOS 扩大按钮的点击范围

iOS 扩大按钮的点击范围

  • 首先要自定义一个按钮 重写方法
    -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
    {
    CGRect bounds = self.bounds;
    CGFloat widthDelta = 44.0 - bounds.size.width;
    CGFloat heightDelta = 44.0 - bounds.size.height;
    bounds = CGRectInset(bounds, -0.5 * widthDelta, -0.5 * heightDelta);
    return CGRectContainsPoint(bounds, point);
    }

  • 按照常理创建按钮

你可能感兴趣的:(iOS 扩大按钮的点击范围)