Reputation: 19418
I m learning core graphics in iphone. I got basics about how to draw. I want to know how can we put any graphics ,say a circle, in a loop so we can move it ? like in JAVA, we use repaint method.
Upvotes: 2
Views: 488
Reputation: 14816
Depending on what you're trying to accomplish, another solution might be to make the element that's moving a separate UIView
/ CALayer
, and animate its position using Core Animation (in which case, the looping and tweening are handled by the system). Highly recommend you start with Getting Started with Graphics and Animation.
Upvotes: 3
Reputation: 70733
On an iPhone, you repeatedly call a view's setNeedsDisplay method using an NSTimer or CADisplayLink. The OS then calls your view's drawRect method to repaint the circle, and/or redraw any other core graphics drawing needed.
You don't loop in an event driven framework. You tell the OS to repeatedly call you back, and then exit your code and wait.
Upvotes: 2