Zoom UILabel & Re-render font at correct size

后端 未结 8 2431
情歌与酒
情歌与酒 2020-12-13 07:23

I have a multi-line UILabel that I want to enable zooming on.

I embedded it with a UIScrollView and set min zoom to .25 and max zoom to 4.

8条回答
  •  忘掉有多难
    2020-12-13 07:59

    iOS 4+

    - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale {
        scrollView.contentScaleFactor = scale;
        for (UIView *subview in scrollView.subviews) {
            subview.contentScaleFactor = scale;
        }
    }
    

    If this gets too intensive and performance is slow, just try setting the contentScaleFactor for only your labels.

提交回复
热议问题