In my app I have a number of small subviews. When the user taps a subview, I place one separate view over top of the tapped subview (same size) and then animate this separate view to full-screen size.
The enlarging view is custom-drawn, which is creating a big problem with this approach. If I create the enlarging view in my main view's viewDidLoad
method and set its frame to full-screen size, the view's drawRect
method is called immediately, and the view is properly rendered full-size. If I then use this view in the animation, everything works as expected.
However, I need this enlarging view to be different depending on which subview was tapped, so I need to re-create/re-draw it each time. The problem is that when I do this in response to a touch event, the view's drawRect
method does not get called until the animation begins, at which time the view's frame is small instead of full-screen, and as a result everything is drawn wrong.
In my code for the touch event, I'm explicitly setting the view's frame to fullscreen and calling setNeedsDisplay
before starting the animation, but this has no effect - drawRect
just isn't called until the animation begins.
Is there any way to force a redraw, so that the view is drawn while its frame is the size I want it to be?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…