我正在尝试为 my 设置动画UIImageView
,使其从高度 x 到高度 y 进行动画处理,并且我有以下代码:
- (void)viewDidLoad
{
[super viewDidLoad];
self.test = [self createNewBarWithValue:800 atLocation:CGPointMake(107, 43)];
}
- (UIImageView*)createNewBarWithValue:(float)percent atLocation:(CGPoint)location
{
UIImageView *newBar = [[[UIImageView alloc] initWithFrame:CGRectMake(location.x, location.y, 107, 43)] autorelease];
newBar.image = [UIImage imageNamed:@"bar.png"];
CABasicAnimation *scaleToValue = [CABasicAnimation animationWithKeyPath:@"transform.scale.y"];
scaleToValue.toValue = [NSNumber numberWithFloat:percent];
scaleToValue.fromValue = [NSNumber numberWithFloat:0];
scaleToValue.duration = 1.0f;
scaleToValue.delegate = self;
newBar.layer.anchorPoint = CGPointMake(0.5, 1);
[newBar.layer addAnimation:scaleToValue forKey:@"scaleUp"];
CGAffineTransform scaleTo = CGAffineTransformMakeScale( 1.0f, percent );
newBar.transform = scaleTo;
return newBar;
}
但是,我在这里什么也没看到。我错过了什么?