放大和缩小 UIView
使用简单的方法按钮放大和缩小 UIView 的最佳方法是什么? (艾伊
(IBAction)zoomin:(int)distance
{
method here
}
(IBAction)zoomout:(int)distance
{
and here
}
what is the best way to zoom in and out of a UIView with a simple method buttons. (e.i
(IBAction)zoomin:(int)distance
{
method here
}
(IBAction)zoomout:(int)distance
{
and here
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以使用两个手指手势识别器来完成:
您必须写下: -
通过此您已经初始化了一个实例,该实例将处理屏幕(或您正在应用此方法的视图)上的两个手指感觉
现在定义如果您识别了两个手指该怎么办:
上面定义的方法不是通过 UIButton 操作自动调用的,但它会简单地解决您的问题
如果您严格想在 IBAction 中使用缩放,则只需执行以下操作:
其中scaleValue是任何浮点值..您可以根据您的应用程序要求进行设置!
我希望它对你有用! :)
It can be done using two finger gesture recognizer:
You have to just write down:-
By this you have initialized an instance which will take care of two finger sensations on the Screen (or View on which you are applying this method)
Now define what to do if you have recognized the two fingers:
The above defined method is called automatically not through the UIButton actions but it will solve your problem with simplicity
If you strictly want to use zoom at IBAction then simply do this:
Where scaleValue is any float value..you can set this up according to your application requirement!
I hope it will work fine for you! :)
Swift 3、4+
用两根手指检测
UIView
的放大/缩小。这是在主视图上监听的示例:Swift 3, 4+
Detect zoom in/out with two fingers for a
UIView
. Here is an example listening on the main view: