-(void)animo10{
CABasicAnimation *basic = [CABasicAnimation animationWithKeyPath:@"bounds"];
[basic setDuration:2];
basic.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 0, self.animoView.bounds.size.width, self.animoView.bounds.size.height)];
basic.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)];
CAKeyframeAnimation *keyFrame = [CAKeyframeAnimation animationWithKeyPath:@"backgroundColor"];
[keyFrame setDuration:5];
keyFrame.values = @[(id)[UIColor redColor].CGColor, (id)[UIColor orangeColor].CGColor, (id)[UIColor yellowColor].CGColor, (id)[UIColor greenColor].CGColor, (id)[UIColor blueColor].CGColor];
keyFrame.keyTimes = @[@(0.3), @(0.5), @(0.6), @(0.7), @(0.9)];
CAAnimationGroup *group = [CAAnimationGroup animation];
[group setDuration:10];
group.animations = @[basic, keyFrame];
[self.animoView.layer addAnimation:group forKey:nil];
}
-(void)animo9{
CATransition *transition = [CATransition animation];
[transition setDuration:2];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromBottom;
[self.animoView.layer addAnimation:transition forKey:nil];
}
-(void)animo8{
CAKeyframeAnimation *keyFrame2 = [CAKeyframeAnimation animationWithKeyPath:@"backgroundColor"];
[keyFrame2 setDuration:3];
keyFrame2.values = @[(id)[UIColor redColor].CGColor, (id)[UIColor orangeColor].CGColor, (id)[UIColor yellowColor].CGColor, (id)[UIColor greenColor].CGColor, (id)[UIColor blueColor].CGColor];
keyFrame2.keyTimes = @[@(0.3), @(0.5), @(0.6), @(0.7), @(0.9)];
[self.animoView.layer addAnimation:keyFrame2 forKey:nil];
}
-(void)animo7{
//1 创建并指定要修改的属性
// KeyPath:CAlayer的属性名, 不是所有的属性都可以, 只有在头文件中出现animatable的属性才可以, 可以修改属性的属性, 例如:bounds.size
// CALayer
CABasicAnimation *basic = [CABasicAnimation animationWithKeyPath:@"bounds"]
[basic setDuration:0.2]
[basic setRepeatCount:100]
//2 修改属性值
basic.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 0, self.animoView.bounds.size.width, self.animoView.bounds.size.height)]
basic.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)]
// basic.byValue =
//3 添加动画
//key做区分动画用
[self.animoView.layer addAnimation:basic forKey:@"changColor"]
}
-(void)animo6{
self.animoView.layer.cornerRadius = 50
//设置圆角, 参数是内切圆的半径, 若想画一个圆, 前提是view必须是正方形, 参数应该是view边长的一半
self.animoView.layer.borderWidth = 1
self.animoView.layer.borderColor = [UIColor orangeColor].CGColor
self.animoView.layer.shadowOffset = CGSizeMake(50, 100)
self.animoView.layer.shadowColor = [UIColor grayColor].CGColor
self.animoView.layer.shadowOpacity = 1
}
-(void)animo5{
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(100, 100, 100, 100)];
layer.path = path.CGPath;
layer.fillColor = [[UIColor clearColor] CGColor];
layer.strokeColor = [[UIColor blackColor] CGColor];
[self.view.layer addSublayer:layer];
}
-(void)animo4{
CABasicAnimation * ani = [CABasicAnimation animationWithKeyPath:@"transform"];
ani.fromValue = @0;
ani.toValue = [NSNumber numberWithFloat:M_PI];
ani.duration = 2;
ani.valueFunction = [CAValueFunction functionWithName:kCAValueFunctionRotateY];
[self.animoView.layer addAnimation:ani forKey:@""];
}
-(void)animo3{
[UIView animateWithDuration:2 delay:1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
[UIView setAnimationRepeatCount:100];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
self.animoView.layer.cornerRadius = 50;
self.animoView.layer.masksToBounds = YES;
self.animoView.layer.borderColor = [[UIColor blackColor] CGColor];
self.animoView.layer.borderWidth = 5;
self.animoView.center = CGPointMake(200, 300);
} completion:^(BOOL finished) {
self.animoView.center = CGPointMake(150 , 150);
[UIView setAnimationsEnabled:YES];
}];
}
-(void)animo2{
[UIView beginAnimations:@"过渡动画" context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationRepeatCount:50];
[UIView setAnimationTransition:4 forView:self.animoView cache:YES];
[UIView commitAnimations];
}
-(void)animo1{
[UIView beginAnimations:@"第一个动画" context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationDelay:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatCount:10];
[UIView setAnimationRepeatAutoreverses:YES];
self.animoView.frame = CGRectMake(200, 200, 50, 50);
self.animoView.backgroundColor = [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1];
[UIView commitAnimations];
}