/**
* 矩阵操作(缩放,旋转)
*/
- (void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);//保存 图形上下文栈
//矩阵操作
CGContextRotateCTM(ctx, M_PI_4 * 0.3);
CGContextScaleCTM(ctx, 0.5, 0.5);
CGContextTranslateCTM(ctx, 0, 150);
CGContextAddRect(ctx, CGRectMake(10, 10, 50, 50));
CGContextAddEllipseInRect(ctx, CGRectMake(100, 100, 100, 100));
CGContextRestoreGState(ctx);//恢复 图形上下文栈
CGContextMoveToPoint(ctx, 100, 100);
CGContextAddLineToPoint(ctx, 200, 200);
CGContextStrokePath(ctx);
}
iOS Quartz2D - 矩阵操作
最新推荐文章于 2018-02-08 12:01:05 发布