Nstimer Timer
[Nstimer scheduledtimerwithtimeinterval:0.025 target:self selector: @selector (update) Userinfo:nil repeats: YES]; // If we use the Nstimer timer. The set line time is 0.025 seconds, if the screen refresh time is 0.035. The middle will wait 0.010
This method is not recommended when drawing a graphic
Cadisplaylink Timer
Additional knowledge: The DrawRect method is called when the view is going to be displayed DrawRectmethod is not manual adjustment?,Because inDrawRectmethod to get the context associated with the view, when the system calls the DrawRect method , it will help you create a context that is associated with the view and pass it to it . Solutions:Want to redraw,Adjustable?[self Setneedsdisplay]; tell the system to redraw view, The system will automatically help you call method , system in call drawrect method , It will help you create the context
Setneedsdisplay: Will call DrawRect, but it is not called immediately, just set a flag. The next time the screen refreshes. // We use the timer when drawing, it is best to use Cadisplaylink. Create a cadisplaylink timer This timer? Is it when the screen refreshes every time it is adjusted? The screen refreshes 60 times per second); // make use of cadisplaylink do not need to consider the time interval. Cadisplaylink *link = [cadisplaylink displaylinkwithtarget:self selector: @selector (update)]; to make it work, you have to add the timer to the main run loop [link Addtorunloop:[nsrunloop mainrunloop]formode:nsdefaultrunloopmode];
iOS development-quartz2d when drawing timer selection