I have an imageview in scrollview (I followed this video https://www.youtube.com/watch?v=0Tz0vI721c8). I want to draw a green dot on that image at x=100, y=100 (from upper left corner of the image). When user zoom in/out and pan, the dot stays at that location (image coord 100,100). How do I do that? I am totally new to ios dev.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setupScrollView()
}
func setupScrollView() {
scrollView.delegate = self
}
}
extension ViewController:UIScrollViewDelegate {
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return imageView
}
}
2
Answers
Create a imageView(dot) to Frame layout, attach dot align top and leading to Frame layout.
Try ur relative object(dot) layout to absolute object(imageView).