我正在使用一个使用CGContext来创建正方形,圆圈和线条的应用程序。当我放大时,我正在设置ImageView的子视图 contentscalefactor 。
代码:
func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
for view in (imageView?.subviews)! {
view.contentScaleFactor = scale;
view.setNeedsDisplay()
}
}
但是,当该代码执行时, APP由于内存警告而终止。当我评论特定行(view.contentscalefactor = scale; scale;(应用程序完美运行。
为此解决任何解决方案?
使用view.transform = CGAffineTransformScale(CGAffineTransformIdentity, scale, scale);
代替view.contentScaleFactor
。