Zoom of an UIView iOS swift || Zoom implementation but subview came with blur || pinch zoom implementation with subview's zoom iOS swift
Solution:
First you have to create one UIView embed in ScrollView.After that implement the scrollView delegate method like Below.
MyView is the that i want to zoom.Assign the delegate of the scrollView to self.
In ViewDidload must add the below code.
scrollView.delegate = self
scrollView.minimumZoomScale = 1.0
scrollView.maximumZoomScale = 10.0
scrollView.isScrollEnabled = true
After that implement the below method
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
if isZoom {
return self.myView } else {
return nil
}
}
If you want to zoom the subviews of the view then implement the below
delegate method.
MyView1 is the subview of myView.You can implement to zoom more views for
that.
func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
myView1.contentScaleFactor = scale
}
Comments
Post a Comment