如何在移动中(PanGestureRecognizer)在UIImageView中添加子视图?
我的代码:
@IBOutlet weak var img: UIImageView!
@objc func PanAction(sender: UIPanGestureRecognizer) {
let imageViewPoint:CGPoint = sender.location(in: img)
var imx:UIImageView?
imx = UIImageView.init(image: #imageLiteral(resourceName: "small"))
img.addSubview(imx!)
imx!.frame.origin = imageViewPoint
}
代码效果不佳,请参见图片。
-正确显示我的代码(✗)
-我需要像左图(✓)一样的结果