CABasicAnimation *leftboundsanimation = [CABasicAnimation animationWithKeyPath:@"bounds.size.width"];
leftboundsanimation.fromValue = [NSNumber numberWithFloat:1];
//[NSValue valueWithCGSize:CGSizeMake(1, 20)];
leftboundsanimation.toValue = [NSNumber numberWithFloat:animationrectwidth/2-0.5];
// [Nilai NValueWithCGSize:CGSizeMake(animasirectwidth/2-0.5, 20)];
leftboundsanimation.removedOnCompletion = NO;
leftboundsanimation.fillMode = kCAFillModeForwards;
leftboundsanimation.duration = 1.3;
leftboundsanimation.beginTime = 2.7;
Versi CABasicAnimation:
Bagaimana untuk menukar lebar CALayer dengan animasi dari kiri ke kanan?
UIView
其实有直接提供动画方法的。改变一个
view
的宽度: