2

我有一个应用程序,它显示从库中选择的歌曲中的艺术作品,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];
}
4

1 回答 1

3

使用 Quartz 核心框架。这是未经测试的,但我想它应该在理论上起作用。

#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"];
于 2013-02-01T17:37:47.847 回答