UIView Animations(storyboard)

本文详细介绍了在iOS4.0之前如何为程序添加动画流程,包括.h和.m文件的具体编写方式,涵盖动画开始、动画内容实现、容器管理以及动画结束的完整流程。

IOS4.0之前如果要给一个程序添加动画流程

.h文件

@interface ViewController : UIViewController
{
    
    __weak IBOutlet UIView *view1;
    
    __weak IBOutlet UIView *view2;
}

- (IBAction)View1Button:(UIButton *)sender;

- (IBAction)View2Button:(UIButton *)sender;

.m文件

// beginAnimations 表示要开始动画
    [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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值