扩大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);
}
-(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);
}
相关文章推荐
- 扩大Button的点击范围,setImage与setBackgroundImage区别
- button扩大可点击范围
- 不改变button大小,扩大点击范围
- Android 扩大view点击范围
- 响应者链UIResponder-扩大UIButton的点击范围
- iOS 扩大 UIButton 的点击范围
- Android 完美扩大ImageView的点击范围方案
- CCControlButton使用时发现的点击范围问题(只能在右下角点击按键)
- 扩大View的点击范围
- label的扩大点击范围影响到了监听事件
- 如何随意改变和拓展button的点击范围
- 一种扩大View点击范围的方法
- 超链接点击范围扩大到外层包含元素
- Android小技巧1——扩大控件的点击范围
- 扩大Button的点击区域
- input checkbox 扩大点击范围的实现方法
- 扩大UIButton点击范围,直接复制黏贴就可以使用
- iOS runtime扩大UIButton点击范围
- iOS扩大按钮UIButton的点击范围
- 扩大Button按钮的点击区域