iPhone: UIImageView Fades in - Howto?

前端 未结 7 1087
礼貌的吻别
礼貌的吻别 2021-02-02 13:22

I have an UIImageView that I want to fade in.

Is there a way to enable that on an underlying UIViewController?

I have translated the s

7条回答
  •  遥遥无期
    2021-02-02 13:41

    Use below in your UIViewController

    // add the image view
    [self.view addSubview:myImageView];
    // set up a transition animation
    CATransition *animate = [CATransition animation];
    [animate setDuration:self.animationDelay];
    [animate setType:kCATransitionPush];
    [animate setSubtype:kCATransitionFade];
    [animate setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    
    [[self layer] addAnimation:animate forKey:@"fade in"];
    

提交回复
热议问题