2. Control-drag the UIScrollView to
@IBOutlet weak var myUIScrollView: UIScrollView!
3. Complete the code as below:
import UIKit
class ViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet weak var myUIScrollView: UIScrollView!
var myUIImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
self.myUIScrollView.maximumZoomScale = 5.0
self.myUIScrollView.minimumZoomScale = 0.5
self.myUIScrollView.delegate = self
myUIImageView = UIImageView(image: UIImage(named: "big_image.png"))
self.myUIScrollView.addSubview(myUIImageView)
}
func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
return myUIImageView
}
No comments:
Post a Comment