Animating a UIImage or UIImageView?

前端 未结 6 646
刺人心
刺人心 2021-02-09 06:18

I\'m trying to animate an image\'s height (from height of 0 pixels to 480 pixels) to create the effect of the image being rendered top-down.

With an UIImageView i notice

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-09 06:43

    Use an animation block like so:

    imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 0)];
    imageView.image = ...;
    [imageView setClipsToBounds:YES];
    [imageView setContentMode:UIViewContentModeTop];
    
    [self.view addSubview:imageView];
    [imageView release];
    
    [UIView animateWithDuration:4.0f
                          delay:1.0f
                        options:UIViewAnimationOptionCurveEaseIn
                     animations:^(void) {
                         imageView.frame = CGRectMake(0, 0, 320, 480);
                     }
                     completion:NULL];
    

提交回复
热议问题