矩阵操作

来源:互联网 发布:打开算法之门 pdf 编辑:程序博客网 时间:2024/05/21 09:25

矩阵操作的简单用法

- (void)drawRect:(CGRect)rect {    //获取上下文    CGContextRef ctx = UIGraphicsGetCurrentContext();    //设置矩阵操作,必须放在绘制图形之前:矩阵操作是对整个layer进行操作    CGContextRotateCTM(ctx, M_PI_4);//旋转    CGContextScaleCTM(ctx, 0.8, 0.8);//放大缩小    CGContextTranslateCTM(ctx, 50, 50);//平移    CGContextAddRect(ctx, CGRectMake(200, 100, 100, 100));    CGContextStrokePath(ctx);}
1 0
原创粉丝点击