IOS development-improves APP smoothness (stock quotes) and iosapp

Source: Internet
Author: User

IOS development-improves APP smoothness (stock quotes) and iosapp

In the past few days, I made an app to view the stock market.

After the completion, when there are many K lines, the app's reaction to kneading and dragging gestures is not smooth,

The main reason is that drawRect: it takes more than 40 ms to work too much, and fps is naturally not high.

Finally, adjust and modify according to the following principles, and improve the smoothness. Most of the drawing time is limited to about 10 ms.

 

Summary:

1. Do not implement drawRect whenever possible (each time this method is called, the backing store should be allocated with memory, which consumes a lot of CPU)

2. Avoid consuming a lot of CPU resources in drawRect:

2. Call setNeedsDisplay as few as possible: (called only when the View content changes)

3. Consider using setNeedDisplayInRect:. The smaller the input drawRect: rect, the smaller the stoke and fill time, even if drawRect: is drawn based on The View boundary)

4. make full use of GPU resources and directly set the border, shadow, corner, gradient, and other attributes of the layer. GPU will process these attributes (On the contrary, if the GPU is tight and the CPU is idle, it should be processed by the CPU, can be implemented in drawRect)

5. if you try to enable drawsAsynchronusly when drawing many things to a view, the GPU will plot the View content to the backing store, but the memory will increase when it is enabled, therefore, you need to evaluate the performance changes before and after enabling, and use them with caution.

 

 

Code: https://github.com/beddup/TradeTraining/tree/master

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.