6.8 Animation动画

- (void)initializeUserface
{

    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"Animation";

    UIButton *botton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    botton.backgroundColor = [UIColor blackColor];

    [botton addTarget:self action:@selector(handleButtonEvent:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:botton];

    //创建nextItem
    UIBarButtonItem *nextItem = [[UIBarButtonItem alloc]initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(handleBarButtonEvent:)];

    self.navigationItem.rightBarButtonItem = nextItem;


}

传值

- (void)handleBarButtonEvent:(id)sender
{
    ImageViewController *imageVC = [[ImageViewController alloc]init];
    [self.navigationController pushViewController:imageVC animated:YES];

}

pragma mark - 普通方式

- (void)handleButtonEvent:(UIButton *)sender
{
#pragma mark - 普通方式
    /*//  配置开始标识
    [UIView beginAnimations:@"position" context:nil];
    //  配置动画时长
    [UIView setAnimationDuration:3];
    //  动画延时
    [UIView setAnimationDelay:0];
    //  配置动画线性规律
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    // 设置代理,获取回调,结束的时候捕获
    [UIView setAnimationDelegate:self];
    // 设置已经结束方法名
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    //  动画逻辑
    sender.center = self.view.center;
    //  提交结束
    [UIView commitAnimations];*/

另一种代码块的方式

#pragma mark - 动画代码块
    // 参数1:动画执行时间
    // 参数2:动画逻辑
    // 参数3:动画执行参数
    // 参数4:执行动画逻辑
    // 参数5:动画完成回调block

    [UIView animateWithDuration:1 animations:^{
        sender.center = self.view.center;
    } completion:^(BOOL finished) {

        [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveLinear |UIViewAnimationOptionTransitionFlipFromLeft  animations:^{

            //放大逻辑
            sender.transform = CGAffineTransformMakeScale(2, 2);
        } completion:^(BOOL finished) {

            [UIView animateWithDuration:1 animations:^{

                //颜色改变
                sender.backgroundColor = [UIColor blueColor];
            } completion:^(BOOL finished) {

                [UIView animateWithDuration:1 animations:^{

                    //旋转(角度会对360求余)
                    sender.transform = CGAffineTransformRotate(sender.transform, M_PI);
                    sender.transform = CGAffineTransformRotate(sender.transform, M_PI);

                } completion:^(BOOL finished) {

                    [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionTransitionCurlUp animations:^{

                        //还原所有transform
                        sender.transform = CGAffineTransformIdentity;
                    } completion:Nil];

                    //转场动画
                    // 参数1:指定视图
                    // 参数2:动画时长
                    // 参数3:动画选项
                    // 参数4:动画逻辑
                    // 参数5:动画完成回调
                    [UIView transitionWithView:sender duration:1 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
                        //还原所有的transform
                        sender.transform = CGAffineTransformIdentity;
                        sender.backgroundColor = [UIColor blueColor];
                    } completion:nil];

                }];
            }];
        }];
    }];

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值