我有一个应用程序,显示从iPod
库中选择的歌曲中的艺术作品,并希望不断旋转。
目前的代码如下:
-(void)chosen:(MPMediaItem*)song withObject:(id)obj
{
AppDelegate* app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
//ARTWORK STUFF
UIImage *artworkImage = [UIImage imageNamed:@"noArtworkImage.png"]
MPMediaItemArtwork *artwork = [song valueForProperty: MPMediaItemPropertyArtwork];
if (artwork)
{
artworkImage = [artwork imageWithSize: CGSizeMake (200, 200) ];
}
[app.viewController.artworkImage1 setImage:artworkImage];
}
答案 0 :(得分:3)
使用Quartz Core Framework。这是未经测试的,但我认为它应该在理论上有效。
#import <QuartzCore/QuartzCore.h>
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = 6;
fullRotation.repeatCount = 1e100f;
[app.viewController.artworkImage1.layer addAnimation:fullRotation forKey:@"360"];