Performance scrolling and retina resolution images in CALayer

前端 未结 3 1581
花落未央
花落未央 2020-12-23 13:28

I have a UIView that is placed as a subview in a UIScrollView. I have several child views made up of images, text, and buttons in the UIView. In order to get decent scrollin

相关标签:
3条回答
  • 2020-12-23 14:00

    I had a similar problem-- a rotated UIView with several UIImageView subviews. When I set the rasterizationScale = 2.0, the images became crisper, but this caused serration to reemerge. To fix this, I created a containerView that held the UIView and UIIMageViews (which were previously subviews of the UIView) and applied rasterizationScale = 1.0 to the UIView and rasterizationScale = 2.0 to the UIImageViews. Now everything looks quite nice.

    0 讨论(0)
  • 2020-12-23 14:03

    @Jamie Hamick's answer in Swift 5:

    myView.layer.rasterizationScale = UIScreen.main.scale

    0 讨论(0)
  • 2020-12-23 14:07

    Seems I needed to set rasterizationScale to the proper value for the device as follows.

    myView.layer.rasterizationScale = [[UIScreen mainScreen] scale];
    
    0 讨论(0)
提交回复
热议问题