gpt4 book ai didi

ios - iOS 5.1 中的 CGGraphics Image Context 动画旋转

转载 作者:行者123 更新时间:2023-11-28 22:52:55 25 4
gpt4 key购买 nike

我正在 iOS 中创建一个旋转旋钮按钮。图形设计师给了我 png 图层,所以我使用图像上下文来混合图层。

在旋转时,只有部分图层会旋转。我的目标是为这些旋转设置动画。

目前,我正在使用

- (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
- (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
- (BOOL)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event

在这些方法中,我计算图像所需的旋转并绘制它。

这很好用。我的障碍是在

- (BOOL)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event

我想做一个“对齐”动画。我怎样才能做到这一点?由于混合,我不确定在这种情况下如何使用仿射变换。以下方法是我构建图像的方式:

- (UIImage *)knobImageWithRadians:(float)radians
{
UIImage *i05 = [UIImage imageNamed:@"05 - Metal Over Empty Space - ROTATE ME.png"];
UIImage *i04 = [UIImage imageNamed:@"04 - Inner Knob.png"];
UIImage *i03 = [UIImage imageNamed:@"03 - Over Knob Metal - (OVERLAY BLEND) - ROTATE ME.png"];
UIImage *i02 = [UIImage imageNamed:@"02 - Numbers and Dashes - ROTATE ME.png"];
UIImage *i01 = [UIImage imageNamed:@"01 - Reflective Overlay - (COLOR DODGE BLEND).png"];

CGSize size = i11.size;

UIGraphicsBeginImageContext(size);
CGContextRef bitmap = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(bitmap, size.width/2, size.height/2);


[i04 drawInRect:CGRectMake(-i04.size.width/2, -i04.size.height/2, i04.size.width, i04.size.height) blendMode:kCGBlendModeNormal alpha:1.0];

CGContextRotateCTM(bitmap, radians);
[i03 drawInRect:CGRectMake(-i03.size.width/2, -i03.size.height/2, i03.size.width, i03.size.height) blendMode:kCGBlendModeOverlay alpha:1.0];

[i02 drawInRect:CGRectMake(-i02.size.width/2, -i02.size.height/2, i02.size.width, i02.size.height) blendMode:kCGBlendModeNormal alpha:1.0];
CGContextRotateCTM(bitmap, -radians);

[i01 drawInRect:CGRectMake(-i01.size.width/2, -i01.size.height/2, i01.size.width, i01.size.height) blendMode:kCGBlendModeColorDodge alpha:1.0];

UIImage* blendedImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return blendedImage;
}

更新:

现在,我只是让它直接捕捉,没有任何动画。

最佳答案

您必须通过定期以新角度重新绘制图像来自己制作动画。或者想出只使用源而不是合成的视觉效果,这样您就可以将每个图像放在一个单独的层中。

关于ios - iOS 5.1 中的 CGGraphics Image Context 动画旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11486625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com