[英]Bigger Touch when touching
我需要一种让用户在按下按钮时拥有更大触感的方法。 这样,用户可以错过按钮,但仍可以单击它。 有没有办法做到这一点? 我不想仅在用户单击的区域更改按钮类。
谢谢!!! ps我很擅长逻辑思维...我只需要一些代码
1)您可以使用[yourButtonType setBackgroundImage:yourImage forState:UIControlStateNormal]; 你可以让你这样的形象,
-------------------------------------------
| transparent, transparent, transparent |
| transparent,yourOpaqueImage, transparent|
| transparent, transparent, transparent |
|------------------------------------------
实际上按钮框较大,但用户无法意识到
2)您可以使用touchesEnded,像这样
- (void)touchesEnded:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint location = [touch locationInView:self];
CGRect btnRect = CGRectMake(btn.frame.origon.x-10,btn.frame.origon.y-10 , btn.frame.size.width+20, btn.frame.size.height+20);
if (CGRectContainsPoint(btnRect, location)) {
//sender your button
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.