iOS Quartz2D - 矩阵操作

来源:互联网 发布:windowsvps搭建数据库 编辑:程序博客网 时间:2024/06/03 23:44
/** *  矩阵操作(缩放,旋转) */- (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);}

0 0
原创粉丝点击