iOS-CGAffineTransform
iOS-CGAffineTransform
1. Transform的定义
scaleX = transform.a
scaleY = transform.d
rotateX = transform.c
rotateY = transform.b
translateX = transform.tx
translateY = transform.ty
2. Transform的逆运算
1 | - (CGFloat)getScaleXFromTransform:(CGAffineTransform)transform { |
3. 使用Transform的注意事项
如果一个 UIView 通过 CGAffineTransformScale 缩放,scale 比例为 0,会导致该 View 及其 Layer 无法获取 CGContext,如果尝试显示、或渲染这样的 View / Layer,会有如下错误日志:
1 | <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. |