Анимация UIImageView - PullRequest
       11

Анимация UIImageView

1 голос
/ 05 сентября 2011

Я пытаюсь оживить мой 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;
}

Однако я ничего здесь не вижу.Чего мне не хватает?

1 Ответ

1 голос
/ 05 сентября 2011

Не похоже, что вы добавляете UIImageView к представлению вашего контроллера вида.

ex

[self.view addSubview:test];
...