1

次のコードで回転した画像を描画しようとしています

CGLayerRef layer=CGLayerCreateWithContext(context,CGSizeMake(brush.size.width*2,brush.size.height*2), NULL);
CGContextRef tmp=CGLayerGetContext(layer);
CGContextDrawImage(tmp,CGRectMake(brush.size.width/2, brush.size.height/2, brush.size.width, brush.size.height), brush.CGImage);

CGContextSetFillColorWithColor(tmp, [UIColor clearColor].CGColor);
CGContextSetBlendMode(tmp, kCGBlendModeClear);
CGContextFillRect(tmp, CGRectMake(0, 0, 2*brush.size.width, 2*brush.size.height));
CGContextSetBlendMode(tmp, kCGBlendModeNormal);
CGContextTranslateCTM(tmp, -brush.size.width/2, -brush.size.height/2);
CGContextRotateCTM(tmp, angle);
CGContextTranslateCTM(tmp, brush.size.width/2, brush.size.height/2);
CGContextDrawImage(tmp,CGRectMake(brush.size.width/2, brush.size.height/2, brush.size.width, brush.size.height), brush.CGImage);

レイヤーの中央に画像を配置したい(画像は正方形)

4

1 に答える 1

0

回転してから平行移動してみてください

于 2012-08-19T19:30:48.913 に答える