donghua

本文深入探讨了iOS开发中动画效果的实现方法,通过具体代码实例展示了不同类型的动画效果,包括透明度变化、旋转、平移和翻页动画等,并提供了关键代码片段和实现细节,帮助开发者掌握iOS动画设计技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

iPhone开发中动画效果实现分类代码是本文要介绍的内容,但是内容不是很多,主要是以代码的形式来实现动画的分类,来看详细代码,希望对你帮助!

{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(resetView)];

CGAffineTransform oneTransform = CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180));
CGAffineTransform twoTransform = CGAffineTransformTranslate(self.animatView.transform,0,-100);
CGAffineTransform newTransform = CGAffineTransformConcat(oneTransform, twoTransform);
[self.animatView setTransform:newTransform];
[UIView commitAnimations];
}
- (void) second_animations
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
[animation setDuration:1];
[animation setRepeatCount:0];
[animation setAutoreverses:YES];//自动反向动画
[animation setFromValue:[NSNumber numberWithFloat:1.0]];
[animation setToValue:[NSNumber numberWithFloat:0]];
[animation setDelegate:self];
[self.animatView.layer addAnimation:animation forKey:@"firstView-Opacity"];
}
- (void) third_animations
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containView cache:YES];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:)];
[UIView commitAnimations];
}
- (void) fourth_animations
{
CATransition *transition = [CATransition animation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = @"pageCurl"; //@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl"
@"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"
transition.subtype = kCATransitionFromRight;
transition.removedOnCompletion = YES;
transition.fillMode = kCAFillModeBackwards;
transition.delegate = self;
[self.animatView.layer addAnimation:transition forKey:nil];
}
-(void) resetView
{
[self.animatView setTransform:CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180))];
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}
#pragma mark Delegate Methods
- (void)animationDidStop:(CAAnimation *) theAnimation finished:(BOOL) flag {
self.animatView.frame = CGRectMake(0, 0, 280, 200);
}

#define degreesToRadian(x) (M_PI * (x) / 180.0)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值