gpt4 book ai didi

iphone - 触摸时触感更大

转载 作者:行者123 更新时间:2023-11-29 04:31:20 25 4
gpt4 key购买 nike

我需要一种方法让用户在按下按钮时有更大的触感。这样用户就可以错过该按钮但仍然单击它。有没有办法做到这一点?我不想只更改用户单击的区域的按钮类..

谢谢!!!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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com