Having problems allowing interaction in UIView animation

前端 未结 5 466
野趣味
野趣味 2021-01-03 12:23

I have the following block of code to fade out an introView(UIView)

// Hide intro view after 5 seconds
[UIView animateWithDuration: 1.0
          delay: 5.0
         


        
5条回答
  •  Happy的楠姐
    2021-01-03 13:21

    I had the same problem with a button that I animated with changing the alpha. Cueing off VinceBurn's answer...

    What you see on the screen during the animation is not what the application sees. The moment >you set your alpha to 0, the alpha is 0 for that view, even if you are still seeing it on the >screen. AND view that have an alpha lower that 0.05 (don't recall the exact number) won't get touch >event.

    … the simple solution of just making the minimum alpha 0.1 instead of 0.0 worked for me:

    [UIView animateWithDuration:0.5
                              delay:0.0
                            options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction
                         animations:^{
                             self.myButton.alpha = 0.1f;
                         }
                         completion:^(BOOL finished){
                         }]
    

    Button registered the touchUpInside all the time with no additional method needed, and there was virtually no difference in appearance from taking the alpha to zero.

提交回复
热议问题