iOS开发给UIView添加动画Animation

self.testView需要添加动画的view

1.翻转动画

  [UIView beginAnimations:@"doflip" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.testView cache:YES];
    [UIView commitAnimations];

2.旋转动画

    CGAffineTransform transform;
    transform = CGAffineTransformRotate(self.testView.transform, M_PI / 6.0);
    [UIView beginAnimations:@"rotate" context:nil];
    [UIView setAnimationDuration:2];
    [UIView setAnimationDelegate:self];
    [self.testView setTransform:transform];
    [UIView commitAnimations];

3.偏移动画

    [UIView beginAnimations:@"move" context:nil];
    [UIView setAnimationDuration:2];
    [UIView setAnimationDelegate:self];
    self.testView.frame=CGRectMake(100,100, 120,100);
    [UIView commitAnimations];

4.翻页效果

    [UIView beginAnimations:@"curlUp" context:nil];
    [UIView setAnimationDuration:1];
    //设置动画淡入淡出
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDelegate:self];
    self.testView.frame=CGRectMake(100,100, 120,100);
    //设置翻页的方向
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.testView cache:YES];
    [UIView commitAnimations];

5.缩放效果

    CGAffineTransform  transform;
    transform = CGAffineTransformScale(self.testView.transform,1.2,1.2);
    [UIView beginAnimations:@"scale" context:nil];
    [UIView setAnimationDuration:2];
    [UIView setAnimationDelegate:self];
    [self.testView setTransform:transform];
    [UIView commitAnimations];

6.取反效果

    CGAffineTransform transform;
    transform=CGAffineTransformInvert(self.testView.transform);
    [UIView beginAnimations:@"Invert" context:nil];
    [UIView setAnimationDuration:2];//动画时常
    [UIView setAnimationDelegate:self];
    [self.testView setTransform:transform];//获取改变后的view的transform
    [UIView commitAnimations];//关闭动画

 

转载于:https://www.cnblogs.com/WJJ-Dream/p/5798506.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值