您的位置:首页 > 其它

定时器+反射变换 --->模拟一个音乐播放器的音乐专辑旋转

2015-10-06 20:42 411 查看
//准备imgView

@property(nonatomic,strong)
UIImageView *imgView;

@end

@implementation ViewController

- (void)viewDidLoad {

[super
viewDidLoad];

#pragma mark 模拟音乐播放器中的专辑旋转

//准备一个背景图片

self.imgView = [[UIImageView
alloc]initWithFrame:CGRectMake(0,
0, 200,
200)];

_imgView.center =
self.view.center;

[_imgView
setImage:[UIImage
imageNamed:@"音乐.png"]];

[self.view
addSubview:_imgView];

//切成一个圆

[_imgView.layer
setCornerRadius:100];

[_imgView.layer
setMasksToBounds:YES];

#pragma mark 给音乐专辑旋转增加一个定时器

//人眼能辨别的间隔为0.2,所以尽量在0.2左右

[NSTimer
scheduledTimerWithTimeInterval:0.08
target:self
selector:@selector(rotationWithMusic)
userInfo:nil
repeats:YES];

}

-(void)rotationWithMusic
{

_imgView.transform =
CGAffineTransformRotate(_imgView.transform,
50);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: