我需要缩放并捏合scrollView,其上的图像应该位于相同的相对位置,例如谷歌地图。
有人知道那个公式吗?
到目前为止我的代码;
func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat){
//print(scale);
self.placePointers(scale: scale)
}
func placePointers(scale: CGFloat)
{
for imageViews in PDFView.scrollView.subviews
{
if(imageViews is UIImageView){
imageViews.removeFromSuperview()
}
}
let xAs = ((scale * CGFloat(300)) - PDFView.scrollView.contentOffset.x)
let yAs = ((scale * CGFloat(300)) - PDFView.scrollView.contentOffset.y)
let rect = CGRect(
origin: CGPoint(x: xAs, y: yAs),
size: CGSize(width: 40, height: 40))
print(PDFView.scrollView.contentScaleFactor);
let imageView = UIImageView(frame: rect)
imageView.image = UIImage(named: "pin_afgerond.png");
PDFView.scrollView.addSubview(imageView)
}