I'm quitely new for the iOS
, so I don't know much of it.
I know how to make UIView
(and its childviews) but I don't know about drawRect
I make a class which inherits from UIView
and make subviews in initWithFrame
method.
I want to draw a NSString
using CGContext
after adding subViews
and move it outside of view after 5 seconds.
Could anyone explain when drawRect
is called and how to move it?
One way to do it would be to draw the string and then start an
NSTimer
. Start a 5 second timer, and when it fires, then you can move it.As for when
-drawRect:
is called - it's called whenever your view needs to be updated. It will be called when your view is first displayed by the OS. After that, it will usually be called when it changes size or shape, or when your code calls[myView setNeedsDisplay:YES]
, which tells the OS to update it.