IOS developmentGraph andDrawThe case study is the content to be introduced in this article, mainly to learnIOS developmentSome details about the drawing, otherwise it will not be able to achieve the effect. For details, refer to the details.
1. iOS supports OpenGL ES and Quartz/UIKit/CoreAnimationDrawInterface. UIKitDrawMust be completed in the main thread.
2. Quartz supports path-based rendering, reverse sampling, filling, image coloring, coordinate transformation, pdf rendering, display parsing, and other functions.
3. UIKit supports line drawing, image and color operations.
4. Core Animation supports Animation rendering.
5. Use DrawRect to draw a View. The following actions are triggered:
1) Move and block a View.
2) Hide and display a View.
3) drag the View.
4) display call setNeedDisplay and setNeedDispalyRect
6. the upper-left corner of UIKit is the origin and the lower-right corner is the destination. CoreAnimation is the origin, and the top right corner is the destination. Use CGContextRotateCTM, CGContextScaleCTM, and CGContextTranslateCTM to change the matrix, or directly use CGAffineTransform to set the transformation matrix.
7. CGContext: You can create different context types for Bitmap and PDF.
1) transformation matrix
2) Crop range
3) Line Drawing attributes
4) curve Accuracy
5) reverse sampling
6) Fill attributes and stroke attributes
7) translucent Properties
8) Color Space
9) Text
10) Color Mixing Mode
8. Use UIGraphicsGetCurrentContext to obtain the current CGContext.
9,
- Uigraphicsbeginimagecontextwitexceptions and UIGraphicsEndImageContext
The code used to contain image rendering.
- Uigraphicsbegin1_contexttofiletodata) and uigraphicsend1_context
Used to include the Code drawn in PDF.
10. Draw the Path, that is, draw the vector. We recommend that you use UIBezierPath, followed by CGPath.
11. Flip screen conversion:
- CGContextTranslateCTM(graphicsContext, 0.0, drawingRect.size.height);
- CGContextScaleCTM(graphicsContext, 1.0, -1.0);
12. Point is usually equal to Pixel, but one Point can be specified to correspond to multiple Pixel.
13. Use UIColor to change the color space.
14. rendering performance:
1) Minimize the number of draw calls
2) Try to use an opaque View
3) Reuse views and tables during screen scrolling
4) You do not need to clear the result of the last painting when you scroll the screen.
5) ReduceDrawStatus switch.
Summary:IOS developmentGraph andDrawI hope this article will be helpful to you!