UIView animation动画、AvAudioPlayer声效、定时器timer
全栈老韩
全栈工程师,擅长iOS App开发、前端(vue、react、nuxt、小程序&Taro)开发、Flutter、React Native、后端(midwayjs、golang、express、koa)开发、docker容器、seo优化等。
声效:
NSString *mp3String=[[NSBundle mainBundle]pathForResource:@"beauty_ok2" ofType:@"mp3"];
NSURL *url=[NSURL fileURLWithPath:mp3String];
NSData *data=[[NSData alloc]initWithContentsOfURL:url];
_audioPlayer=[[AVAudioPlayer alloc]initWithData:data error:nil];
UIView animation动画:
[UIView animateWithDuration:1.2 animations:^{
for(int i=0; i<12; i++)
{
self.starImageView = (UIImageView *)[self.view viewWithTag:STARIMAGEVIEWTAG+i];
self.starImageView.transform = CGAffineTransformMakeRotation(3.0);
self.starImageView.alpha = 0;
[_audioPlayer prepareToPlay];
[_audioPlayer play];
}
} completion:^(BOOL finished) {
for(int i=0; i<12; i++)
{
self.starImageView = (UIImageView *)[self.view viewWithTag:STARIMAGEVIEWTAG+i];
[self.starImageView removeFromSuperview];
}
}];
定时器timer:
starsAnimationTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(doStarsAnimation) userInfo:nil repeats:NO];
[starsAnimationTimer invalidate];
starsAnimationTimer = nil;
发布于2024-01-30 04:57:45
浏览量44·
暂无评论,快来发表第一条评论吧