NSTimer和AVAudioPlayer的简单使用
:NSTimer的使用方法
[NSTimerscheduledTimerWithTimeInterval:0.2 target:selfselector:@selector(changeColor)
userInfo:nil repeats:YES];
//让NSTimer消失的方法
[_timer invalidate];
:AVAudioPlayer的简单使用
//创建音乐文件路径
NSString * musicFilePath = [[NSBundlemainBundle]pathForResource:@"jnstyle"ofType:@"mp3"];
//根据路径创建url路径
NSURL * musicURL = [[NSURL alloc]initFileURLWithPath:musicFilePath];
//创建播放器
AVAudioPlayer *thePlayer = [[AVAudioPlayeralloc]initWithContentsOfURL:musicURL error:nil];
thePlayer.volume = 5;
self.player = thePlayer;