我有一个视图控制器,我在其中设置了一个 UIImageView 并想在 Xcode 中使用 QuartzCore 对其进行动画处理 - 我构建了 UIImage 以生活在一个旋转的图像视图中。当我在自己的项目中对其进行测试时,它旋转得很好,但是现在我将它拉入我当前的工作项目中,它添加了图像视图但没有动画?不知道为什么?有任何想法吗?
我没有任何错误或警告,它与在单独项目中工作的代码相同吗?我还添加了 QuartzCore 库和#imported
- (void)viewDidLoad {
//Setup Image View
UIImage *image = [UIImage imageNamed:@"record01.png"];
UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
[imgView setFrame: CGRectMake(0, 0, image.size.width, image.size.height)];
[imgView setCenter:(CGPoint){160,160}];
[self.view addSubview:imgView];
//Animate Image View
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:2 * M_PI];
fullRotation.duration = 1.5;
fullRotation.repeatCount = HUGE_VALF;
[imgView.layer addAnimation:fullRotation forKey:@"fullRotation"];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
po [[UIApp keyWindow] recursiveDescription] 的控制台
| | <UIImageView: 0x984a9f0; frame = (-6.5 -6.5; 333 333); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x984a040>>
(lldb) po 0x984a040
(int) $2 = 159686720 <CALayer:0x984a040; position = CGPoint (160 160); bounds = CGRect (0 0; 333 333); delegate = <UIImageView: 0x984a9f0; frame = (-6.5 -6.5; 333 333); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x984a040>>; contents = <CGImage 0x9843560>; rasterizationScale = 2; contentsScale = 2>
(lldb)