gpt4 book ai didi

ios - 在 iOS 中使 UIButton 具有与键盘键相同的效果

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:05:04 25 4
gpt4 key购买 nike

我正在开发一个有很多按钮的界面。我想通过键盘按键产生两种效果。

  1. 在 iPhone 键盘中,在按下“G”等键后,在手指离开屏幕之前,您可以随时将手指移动到另一个键,输入将是手指离开屏幕时的键。
  2. 当您按下 iPhone 键盘上的某个键时,该键会以某种方式变大。

因为我也有很多按钮,它们也是像键盘一样的小按钮。所以我认为这个效果将帮助用户更轻松地按下按钮而不会出错。普通的 UIButton 可以做到这一点吗?

提前致谢!

最佳答案

您可以使用这个 MagnifyingGlass为了那个效果。对于其他效果,您应该阅读 Touch Events

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];

CGPoint location = [touch locationInView:self.view];

if (location.x >= img.x && location.x <= img.x && location.y >= img.y && location.y <= img.y)
{
// your code here...
}

关于ios - 在 iOS 中使 UIButton 具有与键盘键相同的效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15412944/

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