UIbezierpaths in a zoomable view

2019-04-10 07:38发布

I draw bezierpaths in a zoomable UIView (drawing layer of a pdf reader). When I zoom in the document the UIView zoom in too, but then all the drawings and lines looks much more pixelated. Is there a way to render those paths without too much pixelation? It supposed that bezier paths are vectorial based...

Thanks in advance!

2条回答
看我几分像从前
2楼-- · 2019-04-10 08:28

You can use CAShapeLayer instead. Just create CAShapeLayer, add CGPath and add a layer as sublayer to your UIView layer

查看更多
唯我独甜
3楼-- · 2019-04-10 08:29

You are correct that a UIBezierPath is vector based. However, when you draw a path into a view, it uses the contentScale property on the views layer to determine the amount of detail to use when drawing.

What you could do is when the user finishes zooming, set the content scale to the correct amount.

drawingView.layer.contentScale = [[UIScreen mainScreen] scale] * zoomAmount;

查看更多
登录 后发表回答