Swift:UIImageView Scrollview在缩放时无法正常工作

时间:2017-10-02 21:15:46

标签: ios swift uiscrollview uiimageview

我正在尝试为我的imageView添加缩放到我的应用的功能,但它无法正常工作。我将imageView添加到scrollView并添加了此代码,完全不起作用。

@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!

override func viewDidLoad() {
    super.viewDidLoad()

    // Add Image
    imageView.image = UIImage(named: "\(groupChoice)_\(insideChoice)")

    // Add Zoom
    scrollView.minimumZoomScale = 1.0
    scrollView.maximumZoomScale = 10.0
    scrollView.alwaysBounceVertical = false
    scrollView.alwaysBounceHorizontal = false
    scrollView.showsVerticalScrollIndicator = true
    scrollView.contentSize = imageView.frame.size
    imageView.clipsToBounds = false
}

func viewForZooming(in scrollView: UIScrollView) -> UIView? {
    return imageView
}

0 个答案:

没有答案