如果通过在iphone中捏UIButton来增加大小

时间:2022-11-11 12:25:50

I have a UIButton & want to increase the size of UIButton by pinching the UIButton.Is it possible with UIButton similarly to UIImageView.

我有一个UIButton并希望通过捏UIButton来增加UIButton的大小。使用UIButton可以与UIImageView类似。

2 个解决方案

#1


1  

Yes it is. Just get the gesture and then scale your button accordingly.

是的。只需获取手势,然后相应地缩放按钮。

#2


0  

Here you have nice tutorial with gesture recognizers. For pinching use UIPinchGestureRecognizer after hooking it up you can retrieve scale of pinching easily. In your case don't use affine transform to scale, because it will cause blurring of the button. Instead, you should calculate frame of button by hand. This is more complicated, but result should be exactly what you want.

在这里,你有一个很好的教程与手势识别器。对于捏合使用UIPinchGestureRecognizer后,您可以轻松检索捏缩的比例。在你的情况下,不要使用仿射变换来缩放,因为它会导致按钮模糊。相反,你应该手动计算按钮的框架。这更复杂,但结果应该是你想要的。

#1


1  

Yes it is. Just get the gesture and then scale your button accordingly.

是的。只需获取手势,然后相应地缩放按钮。

#2


0  

Here you have nice tutorial with gesture recognizers. For pinching use UIPinchGestureRecognizer after hooking it up you can retrieve scale of pinching easily. In your case don't use affine transform to scale, because it will cause blurring of the button. Instead, you should calculate frame of button by hand. This is more complicated, but result should be exactly what you want.

在这里,你有一个很好的教程与手势识别器。对于捏合使用UIPinchGestureRecognizer后,您可以轻松检索捏缩的比例。在你的情况下,不要使用仿射变换来缩放,因为它会导致按钮模糊。相反,你应该手动计算按钮的框架。这更复杂,但结果应该是你想要的。