UIView. How do I constrain scaling to one dimension only

前端 未结 3 1862
梦如初夏
梦如初夏 2020-12-10 08:58

I have an instance of UIScrollview containing an instance of UIView. The UIView is just a container for a horizonal array of UIImageView instances. - Zooming is provided by

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 09:12

    Using OS 3.0, you can tell the zoom to zoom to a rect in the scrollview. I have this in my logic that detects taps.

    CGRect zoomRect = [self zoomRectForScale:newScale withCenter:CGPointMake(tapPoint.x, tapPoint.y) inScrollView:scrollView];
    [scrollView zoomToRect:zoomRect animated:YES];
    

    The for the other part, you will have to stretch your image views by the ratio that the new frame has against the original, and center it in the same center point. You can do this in an animation timed the same as the zoom animation so that it looks right, but I think this will be the only way to do it.

提交回复
热议问题