小编kas*_*rjj的帖子

CGContext旋转

我有一个100x100像素的图像,我希望以围绕图像中心旋转的各种角度绘制.以下代码有效,但围绕坐标系的原始原点(左上角)而不是翻译位置旋转.因此,图像不会围绕自身旋转,而是围绕屏幕的左上角旋转.

以下代码在空白应用程序的自定义视图中运行,除此之外别无其他.

- (void)drawRect:(CGRect)rect {
  CGContextRef context = UIGraphicsGetCurrentContext();
  CGContextTranslateCTM(context, -50, -50);
  CGContextRotateCTM (context, 0.3);
  CGContextTranslateCTM(context,768/2,1024/2);
  [image drawAtPoint:CGPointMake(0,0)];
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用CGAffineTransform做同样的事情,但得到了相同的结果.

iphone cocoa-touch core-graphics uikit ipad

6
推荐指数
1
解决办法
9429
查看次数

标签 统计

cocoa-touch ×1

core-graphics ×1

ipad ×1

iphone ×1

uikit ×1