Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImageView Zoom/Fade animation?

I want to make a little zoom/fade animation for when the UIImageView shows up in my view, I already have the code for the fade effect:

    banner.alpha = 0.0;
    [UIView animateWithDuration:2.0 animations:^{
        banner.alpha = 1.0;
    }];

Now I want to know if there is another easy way to combine the fade effect with a little zoom effect, like the image becoming larger and filling up the frame as it fades in? Any ideas? Thanks!

like image 610
Jon Sullivan Avatar asked Dec 07 '22 09:12

Jon Sullivan


2 Answers

you can use CG_EXTERN CGAffineTransform CGAffineTransformMakeScale(CGFloat sx, CGFloat sy) to do the zoom effect

such as

banner.alpha = 0.0;

[UIView animateWithDuration:2.0 animations:^{
    banner.alpha = 1.0;
    banner.transform =CGAffineTransformMakeScale(1.3,1.3);
}];
like image 51
Guo Luchuan Avatar answered Jan 02 '23 00:01

Guo Luchuan


You can also use the frame

banner.alpha = 0;

[UIView animateWithDuration:2.0f animations:^(void){
   banner.alpha = 1.0f;
   [banner setFrame:CGRectMake(0, 0, 1024, 748)];
}];

// With Completion
[UIView animateWithDuration:0.1f animations:^(void){
   banner.alpha = 1.0f;
   [banner setFrame:CGRectMake(0, 0, 1024, 748)];
}completion:^(BOOL finished) {

}];
like image 27
T0m_Twt Avatar answered Jan 02 '23 00:01

T0m_Twt