IOS4.0之前如果要给一个程序添加动画流程
.h文件
@interface ViewController : UIViewController
{
__weak IBOutlet UIView *view1;
__weak IBOutlet UIView *view2;
}
- (IBAction)View1Button:(UIButton *)sender;
- (IBAction)View2Button:(UIButton *)sender;
.m文件
[UIView beginAnimations:@"aa" context:@"gg"]; //设置动画
//以下是动画内容
view1.backgroundColor = [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1]; //随机颜色
CGFloat x = arc4random_uniform(320);
CGFloat y = arc4random_uniform(480);
view1.center = CGPointMake(x,y); //中心点随机
[UIView setAnimationDuration:3]; //动画时间
[UIView commitAnimations]; //动画结束
UIView 分为2中 一种 属性动画{ frame conter等}
第二种 过渡动画 是系统封装好的动画
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view1 cache:YES];
需要有一个容器,先把已有的容器删除掉,在添加进新的视图
Begin an animation block.
Set the transition on the container view.
Remove the subview from the container view.
Add the new subview to the container view.
Commit the animation block.
本文详细介绍了在iOS4.0之前如何为程序添加动画流程,包括.h和.m文件的具体编写方式,涵盖动画开始、动画内容实现、容器管理以及动画结束的完整流程。

482

被折叠的 条评论
为什么被折叠?



