ios 开发如何放大热区

来源:互联网 发布:网络棋牌判刑 编辑:程序博客网 时间:2024/06/06 09:28
@interface YDUIButton : UIButton@end

@implementation YDUIButton- (instancetype)initWithFrame:(CGRect)frame{    self = [super initWithFrame:frame];    if (self) {            }    return self;}- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent*)event{    CGRect bounds = self.bounds;   // 获取当前的bounds    CGFloat widthDelta = MAX(44.0 - bounds.size.width, 0);  // 如果width大于或者等于44 则为0    CGFloat heightDelta = MAX(44.0 - bounds.size.height, 0);    // 相当于把 x和y的坐标点改成了 -x, -y 往上下移动了一段距离    bounds = CGRectInset(bounds, -0.5 * widthDelta, -0.5 * heightDelta);    return CGRectContainsPoint(bounds, point);}@end

0 0
原创粉丝点击