Having problems allowing interaction in UIView animation

前端 未结 5 427
野趣味
野趣味 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条回答
  •  执笔经年
    2021-01-03 12:58

    Are you setting your button alpha to 0?
    If yes here is an interesting thing about animation.

    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.
    Also, a view that has an alpha lower that 0.05 (don't recall the exact number) won't get touch event.

    What you can do is to implement the - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event of that view's superview. or the touchesEnded... as you like.
    (Assuming that your not setting it's alpha to 0.)

    So you can test for touche that occur where the button is, or just remove that button and let any touch on the screen cancel your animation.


    You may also be interested in this post:
    Core Animation, unexpected animated position and hitTest values

提交回复
热议问题