开发者

UIScrollView: keep frames of subviews during zoom

开发者 https://www.devze.com 2023-02-06 13:37 出处:网络
I have a big content view within UIScrollVie开发者_Python百科w that contains subviews. When I zoom, I want to keep frames of that subviews unchanged. In my current solution I use the following:

I have a big content view within UIScrollVie开发者_Python百科w that contains subviews. When I zoom, I want to keep frames of that subviews unchanged. In my current solution I use the following: I override setTransform in my content view and for each subview I apply inverted transform as follows:

- (void)setTransform:(CGAffineTransform)newValue {
   for (SubView *subView in self.subviews) {
      subView.transform = CGAffineTransformInvert(newValue);
   }
   [super setTransform:newValue];
}

it works for my subviews sizes (frame.size.), but I always have some small (sometimes not small) offset in frame.origin. of my subviews.

How should I calculate correct frame.origin for my subviews? I need to get the same functionality as in maps application when after zoom we have the same initial position of annotation view.

Thanks

0

精彩评论

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