标签:
》1.属性动画
// UIView动画 第一种方式 参数:时间间隔 [UIView animateWithDuration:3 animations:^{ self.aView.frame = CGRectMake(200, 400, 100, 100); self.aView.backgroundColor = [UIColor redColor]; self.aView.alpha = 0.2; }]; // UIView动画 第二种方式 --- 先在规定的 [UIView animateWithDuration:3 animations:^{ self.aView.frame = CGRectMake(200, 400, 100, 100); self.aView.backgroundColor = [UIColor redColor]; self.aView.alpha = 0.2; } completion:^(BOOL finished) { [UIView animateWithDuration:3 animations:^{ self.aView.frame = [UIScreen mainScreen].bounds; }]; }]; // UIView动画三 动画的标识 [UIView beginAnimations:nil context:nil]; // 设置动画时间 [UIView setAnimationDuration:0.1]; // 设置动画重复的次数 [UIView setAnimationRepeatCount:100]; // 设置动画延迟时间 [UIView setAnimationDelay:3]; // 设置透明度 self.aView.alpha = 0.1; // 提交动画 /[UIView commitAnimations]; // UIView 动画四 [UIView transitionFromView:self.bView toView:self.aView duration:0.5 options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState |UIViewAnimationOptionTransitionCurlUp completion:^(BOOL finished) { NSLog(@"哈哈"); }]; // UIView 动画五 [UIView transitionWithView:self.view duration:1 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ [self.bView removeFromSuperview]; [self.view addSubview:self.aView]; } completion:^(BOOL finished) { NSLog(@"afgadsfgdsag"); }];
》2.UIViewTransform动画
// 动画6 [UIView animateWithDuration:1 animations:^{ // 旋转 self.bView.transform = CGAffineTransformRotate(self.bView.transform, M_PI); // 放大缩小(在上一次的基础上) // self.bView.transform = CGAffineTransformScale(self.bView.transform, 0.5, 0.5); // 放大缩小(基于原始的fram 值执行一次) self.bView.transform = CGAffineTransformMakeScale(0.5, 0.5); self.bView.transform = CGAffineTransformMakeScale(0.5, 0.5); self.bView.transform = CGAffineTransformMakeScale(0.1, 0.1); }]; // CABasicAnimation --- 基本layer动画,设置初始和结束执行动画 // position CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; // 起始值 animation.fromValue = [NSValue valueWithCGPoint:CGPointMake(self.aView.frame.origin.x, self.aView.frame.origin.y)]; animation.byValue = [NSValue valueWithCGPoint:CGPointMake(100, 0)]; // 结束点 animation.toValue = [NSValue valueWithCGPoint:CGPointMake(300, 500)]; // 返回的时候---设置动画 animation.autoreverses = YES; // 设置动画时间 animation.duration = 3; // 重复动画的次数 animation.repeatCount = 1; // 把动画添加到指定的view的layer层上 [self.aView.layer addAnimation:animation forKey:@"bc"]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"]; // 起始值 animation.fromValue = [NSNumber numberWithFloat:1.0]; // 结束点 animation.toValue = [NSNumber numberWithFloat:0.0]; animation.autoreverses = YES; // 设置动画时间 animation.duration = 1; // 重复动画的次数 animation.repeatCount = 1; // 把动画添加到指定的view的layer层上 [self.aView.layer addAnimation:animation forKey:@"bc"]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; self.aView.transform = CGAffineTransformRotate(self.aView.transform, M_PI); // 放大缩小(在上一次的基础上) self.aView.transform = CGAffineTransformScale(self.aView.transform, 0.5, 0.5); // animation.byValue = [NSValue valueWithCGPoint:CGPointMake(100, 0)]; // 返回的时候---设置动画 // animation.autoreverses = YES; // 设置动画时间 animation.duration = 3; // 重复动画的次数 animation.repeatCount = 1; // 把动画添加到指定的view的layer层上 [self.aView.layer addAnimation:animation forKey:@"bc"]; // CAKeyFrameAnimation动画 CAKeyframeAnimation *keyAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; keyAnimation.values = @[ [NSValue valueWithCGPoint:CGPointMake(50, 100)], [NSValue valueWithCGPoint:CGPointMake(50, 150)], [NSValue valueWithCGPoint:CGPointMake(50, 200)], [NSValue valueWithCGPoint:CGPointMake(50, 250)], [NSValue valueWithCGPoint:CGPointMake(50, 300)], [NSValue valueWithCGPoint:CGPointMake(50, 300)], [NSValue valueWithCGPoint:CGPointMake(50, 300)], [NSValue valueWithCGPoint:CGPointMake(100, 300)], [NSValue valueWithCGPoint:CGPointMake(150, 300)], [NSValue valueWithCGPoint:CGPointMake(200, 300)], [NSValue valueWithCGPoint:CGPointMake(250, 300)], [NSValue valueWithCGPoint:CGPointMake(300, 300)], [NSValue valueWithCGPoint:CGPointMake(350, 300)], [NSValue valueWithCGPoint:CGPointMake(300, 250)], [NSValue valueWithCGPoint:CGPointMake(300, 200)], [NSValue valueWithCGPoint:CGPointMake(300, 150)], [NSValue valueWithCGPoint:CGPointMake(300, 100)], [NSValue valueWithCGPoint:CGPointMake(300, 50)], [NSValue valueWithCGPoint:CGPointMake(250, 50)], [NSValue valueWithCGPoint:CGPointMake(200, 300)], [NSValue valueWithCGPoint:CGPointMake(150, 300)], [NSValue valueWithCGPoint:CGPointMake(100, 250)], [NSValue valueWithCGPoint:CGPointMake(50, 200)] ]; // 返回的时候---设置动画 keyAnimation.autoreverses = YES; // 设置动画时间 keyAnimation.duration = 1; // 动画次数 keyAnimation.repeatCount = 10; // [self.aView.layer addAnimation:keyAnimation forKey:@"bc"]; // 移除动画 // [self.aView.layer removeAllAnimations]; // 移除指定的动画 // [self.aView.layer removeAnimationForKey:@"bc"]; // CATransition动画 CATransition *tansitionAnimation = [CATransition animation]; tansitionAnimation.type = @"push"; tansitionAnimation.subtype = kCATransitionFromBottom; // tansitionAnimation.subtype = kCATransitionFromLeft; // 动画时间 tansitionAnimation.duration = 1; //[self.aView.layer addAnimation:tansitionAnimation forKey:@"transition"]; // CAAnimationGroup组动画 CAAnimationGroup *groupAnimation = [CAAnimationGroup animation]; groupAnimation.animations = @[tansitionAnimation]; // groupAnimation.duration = 10; [self.aView.layer addAnimation:groupAnimation forKey:@"group"];
标签:
原文地址:http://www.cnblogs.com/bachl/p/4693072.html