我如何缩放整个屏幕(包括标签、按钮和图像)? IOS, Swift 3
How do i pinch to zoom the entire screen (including labels, buttons and images)? IOS, Swift 3
此代码似乎不起作用。想知道我在做什么 wrong/missing。我假设我:将 UIPinchGestureRecognizer 拖放到 viewcontroller(这样它就不会干扰与按钮、标签等的连接,并且它已连接到 viewcontroller);然后执行此代码(确保连接正确):
import UIKit
class AlertController: UIAlertController {
@IBAction func scaleImage(sender: UIPinchGestureRecognizer) {
self.view.transform = CGAffineTransformScale(self.view.transform, sender.scale, sender.scale)
sender.scale = 1
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = UIColor.blackColor()
}
override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning()
}
}
请帮忙!
您可以将可缩放的 UIView 放入 UIScrollView 中,然后实现此方法
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return self.view
}
你还需要设置你的 scrollView 委托并设置你的 self.scrollView.maximumZoomScale
> self.scrollView.minimumZoomScale
像这样
self.scrollView.delegate = self
self.scrollView.maximumZoomScale = 2.0
self.scrollView.minimumZoomScale = 0.5
然后使用俯仰手势必须缩放你的`self.view
希望对您有所帮助,祝好
此代码似乎不起作用。想知道我在做什么 wrong/missing。我假设我:将 UIPinchGestureRecognizer 拖放到 viewcontroller(这样它就不会干扰与按钮、标签等的连接,并且它已连接到 viewcontroller);然后执行此代码(确保连接正确):
import UIKit
class AlertController: UIAlertController {
@IBAction func scaleImage(sender: UIPinchGestureRecognizer) {
self.view.transform = CGAffineTransformScale(self.view.transform, sender.scale, sender.scale)
sender.scale = 1
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
view.backgroundColor = UIColor.blackColor()
}
override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning()
}
}
请帮忙!
您可以将可缩放的 UIView 放入 UIScrollView 中,然后实现此方法
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return self.view
}
你还需要设置你的 scrollView 委托并设置你的 self.scrollView.maximumZoomScale
> self.scrollView.minimumZoomScale
像这样
self.scrollView.delegate = self
self.scrollView.maximumZoomScale = 2.0
self.scrollView.minimumZoomScale = 0.5
然后使用俯仰手势必须缩放你的`self.view
希望对您有所帮助,祝好