您的位置:首页 > 其它

扩大Button点击范围

2017-01-09 10:12 381 查看
重写一个Button类,继承自UIButton,重写

 -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)evrnt {

   修改bounds的值,x值为负,x方向扩展,y值为负,y方向上扩欧战

    //希望点击的范围宽高,我暂定90

    float   width =  90 - bounds.size.width;

    float  height =  90 - bounds.size.height;

   bounds = CGRectInset(bounds, 0 , -0.5 * height);

  return CGRectContainsPoint(bounds,point);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息