iOS development-quartz2d when drawing timer selection

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.