Scaling UITextView using contentScaleFactor property

前端 未结 3 424
面向向阳花
面向向阳花 2020-12-16 07:37

I am trying to create a higher resolution image of a UIView, specifically UITextView.

This question and answer is exactly what I am trying

3条回答
  •  萌比男神i
    2020-12-16 08:27

    Be sure to apply the contentScaleFactor to all subviews of the UITextView. I've just tested the following with a UITextView and found it to work:

    - (void)applyScale:(CGFloat)scale toView:(UIView *)view {
        view.contentScaleFactor = scale;
        view.layer.contentsScale = scale;
        for (UIView *subview in view.subviews) {
            [self applyScale:scale toView:subview];
        }
    }
    

提交回复
热议问题