我需要一种方法让用户在按下按钮时有更大的触感。这样用户就可以错过该按钮但仍然单击它。有没有办法做到这一点?我不想只更改用户单击的区域的按钮类..
谢谢!!! p.s我非常擅长逻辑思维...我只需要一些代码
最佳答案
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
}
}
关于iphone - 触摸时触感更大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11705447/