How do I adjust a Quartz 2D context to account for a Retina display?

纵饮孤独 提交于 2019-12-01 08:09:30
Brad Larson

You don't need to change anything in your Quartz code to account for the Retina display. If the correct contentScaleFactor is set on your UIView or CALayer using code like the following:

if ([view respondsToSelector:@selector(setContentScaleFactor:)])
{
    view.contentScaleFactor = [[UIScreen mainScreen] scale];
}

the 2-D drawing you do within -drawRect: or -drawInContext: will be automatically rendered sharply for the Retina display. Remember that the coordinates you specify for the Quartz drawing will be in points, not pixels. With a scale factor of 2.0 for a Retina display, 1 point = 2 pixels.

See the "Updating Your Custom Drawing Code" section in the iOS Application Programming Guide for more.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!