Can some one suggest the best way to do this..
In the Below Image
What I did..
Added a UIImageView inside a UIScrollView(for zoom in/out) and on viewDidAppear() manually added invisible button for the UIImage like this.
self.image.frame = CGRect(x: xValue , y:yValue, width: 60, height: 60)
Is there any better solution for finding the UIImage coordinates?
Very late to the party, but this should work:
in ViewDidLoad
add this:
scrollView.minimumZoomScale = 0.5
scrollView.maximumZoomScale = 6.0
scrollView.contentSize = self.imageView.frame.size
scrollView.delegate = self
After ViewDidLoad
add this:
// MARK: - Update the minimum zoom scale each time the controller updates its subviews
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
updateMinZoomScaleForSize(view.bounds.size)
}
Then create a file private function to calculate the zoom scale for scrollView
fileprivate func updateMinZoomScaleForSize(_ size: CGSize) {
let widthScale = size.width / imageView.bounds.width
let heightScale = size.height / imageView.bounds.height
let minScale = min(widthScale, heightScale)
imageScrollView.minimumZoomScale = minScale
imageScrollView.zoomScale = minScale
}
Are you using nine imageViews? No. it's not correct it seems.
Try like this :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.