Position a View for drawing via renderInContext:

旧街凉风 提交于 2019-12-03 08:55:46

The geometry of the graphics context can be adjusted to the UIViews geometry with this snippet:

// Center the context around the view's anchor point
CGContextTranslateCTM(context, [view center].x, [view center].y);
// Apply the view's transform about the anchor point
CGContextConcatCTM(context, [view transform]);
// Offset by the portion of the bounds left of and above the anchor point
CGContextTranslateCTM(context,
                      -[view bounds].size.width * [[view layer] anchorPoint].x,
                      -[view bounds].size.height * [[view layer] anchorPoint].y);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!