App Optimization Chapter

Source: Internet
Author: User

Uiimageview Efficient and rounded corners

Typically, clipstobounds and Layer.cornerradius force the core animation to render off-screen drawing of the screen in advance, affecting performance.

The Path.addclip () is achieved by cutting the picture with Bezier curve.

The drawrect is called in the following cases:

1. If the rect size is not set at UIView initialization, the drawrect will not be automatically called. The DrawRect is dropped after the Controller->loadview, Controller->viewdidload two method. So don't worry. In the controller, The drawrect of the view began to draw. This allows you to set some values in the controller to the view (if some variable values are needed for these view draw).
2, this method is called after calling SizeToFit, so you can call SizeToFit to calculate the size first. The system then automatically calls the DrawRect: method.
3, by setting the Contentmode property value to Uiviewcontentmoderedraw. The drawrect will be called automatically each time the frame is set or changed:.
4. Call Setneedsdisplay directly

DrawRect methods use note points:

1, DrawRect: Method can not manually display the call, you must call Setneedsdisplay or Setneedsdisplayinrect, let the system automatically tune the method.
2, if using Calayer drawing, can only be drawn in Drawincontext: (similar to DrawRect), or in the corresponding method of delegate. Also call Setneeddisplay and so on indirectly call the above method
3, for real-time drawing, cannot use Gesturerecognizer, can only use Touchbegan and other methods to call Setneedsdisplay real-time refresh screen layoutsubviews in the following cases will be called: 1, Init initialization does not trigger layoutsubviews.
2, Addsubview will trigger layoutsubviews.
3, set the frame of the view will trigger Layoutsubviews, of course, if the frame value has changed before and after the setting.
4, rolling a uiscrollview will trigger layoutsubviews.
5. Rotating screen will trigger the Layoutsubviews event on the parent UIView.
6, changing the size of a uiview will also trigger the parent UIView on the Layoutsubviews event. 7, call Setlayoutsubviews directly.

App Optimization Chapter

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.