开发者

Programmatically Scale selected UIView components on Zoom

开发者 https://www.devze.com 2023-01-19 13:21 出处:网络
I have a UIScrollView that nests a UIImage and several symbols that are placed on the image programatically.

I have a UIScrollView that nests a UIImage and several symbols that are placed on the image programatically.

When the user zooms I need to scale these symbols up to have them keep the same size, whilst the underlying image is zoomed.

I placed the symbols and the image in a UIView to ensure the symbol position is alidned to image coordinates.

First attempt:

My attempt to do this is to place a routine in the viewForZoomingInScrollview method. But when reading the myScrollView.zoomScale parameter I hit the recursion problem that causes an infinte loop on vi开发者_开发知识库ewForZoomingInScrollview (see stackoverflow bug report).

I now struggle to find a way to determine the current zoomScale, hence am unable to determine the scale-factor that I need to apply when scaling my symbols.

Any hints how I can do this?


I solved this by doing the following

a) have the zommable content attached to a UIView that sits below the UIScrollView b) point viewForZoomingInScrollView to this UIView c) add non-zooming objects next to the UIView below the UIScrollView d) add methods to recalculate the non-zomming-object-coordinates based on the zoomScale.

does it for me ...

0

精彩评论

暂无评论...
验证码 换一张
取 消