animation iOS实现动画

来源:互联网 发布:博客绑定域名 编辑:程序博客网 时间:2024/06/04 17:43
//    UIVIEW动画
//    动画特点:全部都是类方法 直接类去调用
//    1.UIView 直接调用的
//    2.Block方法
    
//    步骤:
//    1.开始动画
//    2.------中间写你要执行的动画
//    3.提交动画
    
//    开始动画
//    参数1 动画的ID
//    参数2 携带的参数
    
//    [UIView beginAnimations:@"donghua" context:@"hahaha"];
//    
////    设置动画
////    设置动画执行的时间
//    [UIView setAnimationDuration:1];
////    延时
////    [UIView setAnimationDelay:2];
////    是否反转
//    [UIView setAnimationRepeatAutoreverses:YES];
////    执行的次数
//    [UIView setAnimationRepeatCount:4];
////    是否继续执行
//    [UIView setAnimationBeginsFromCurrentState:YES];
////    设置下代理
//    [UIView setAnimationDelegate:self];
////    需要我们自己设置代理方法
//    [UIView setAnimationWillStartSelector:@selector(animationWillStart:context:)];
//    [UIView setAnimationDidStopSelector:@selector(animationDidStop)];
//    self.imageV.backgroundColor = [UIColor redColor];
//    self.imageV.alpha = .4;
//    //    改变位置
//    self.imageV.frame = CGRectMake(100, 100, 200, 200);
//    
////    提交动画
//    [UIView commitAnimations];
    
    
//    UIView的Block方法
//    2D仿射 (收拾的方法)
#pragma mark -- 平移
//    [UIView animateWithDuration:2 animations:^{
////        你要执行的动画
////        改变视图的形变属性
//        self.imageV.transform = CGAffineTransformTranslate(self.imageV.transform, 100, 100) ;
//    } completion:^(BOOL finished) {
////        block里面在嵌套一个block
//       [UIView animateWithDuration:2 animations:^{
//           //        动画结束后执行的block
//           self.imageV.transform = CGAffineTransformTranslate(self.imageV.transform, -100, -100);
//       } completion:^(BOOL finished) {
//           
//       }];
//    
//
//        
//    }];
#pragma mark -- 缩放
//    
//    [UIView animateWithDuration:1 animations:^{
//        //    填的是比例
//        self.imageV.transform = CGAffineTransformScale(self.imageV.transform, 2, 2);
//
//    } ];
    
#pragma mark -- 旋转
//    切换状态
    _isRunning = !_isRunning;

    [self imageViewRomate];
    
    
    
    
//    
//    NSURL *url = [NSURL URLWithString:@"http://pica.nipic.com/2007-11-08/2007118171913119_2.jpg"];
//    NSData *data = [NSData dataWithContentsOfURL:url];
//    UIImage *image = [UIImage imageWithData:data];
//    self.imageV.image = image;
    
    
    
  //  NSLog(@"点我啊");

}

0 0