QUARTZ2D Study Summary

Source: Internet
Author: User

    • Quartz 2D is a two-dimensional drawing engine that supports both iOS and Mac systems
    • Quartz 2D can do the work

1. Drawing: line \ triangle \ rectangle \ Circle \ Arc, etc.

2. Drawing text

3. Draw \ Generate picture (image)

4. read \ Generate PDF

5. \ crop a picture

6. Custom UI Controls ...

    • The value of quartz2d in iOS development

Use the controls provided by the Uikit framework to cobble together, build and present some simple, common UI interfaces

However, some UI interfaces are extremely complex and more personalized and cannot be implemented with normal UI controls, so you can use quartz2d technology to draw the structure inside the control and customize what the control looks like

In fact, the contents of most controls in iOS are drawn through quartz2d.

As a result, quartz2d is an important value in iOS development: Custom view (custom UI controls)

    • Graphics context: is a cgcontextref type of data

The role of the graphics context

1. Save drawing information, drawing status

2. Decide where to draw the output target (where to draw?) (The output target can be a PDF file, a bitmap, or a display window)

    • Steps to customize view

1. Create a new class that inherits from UIView

2. Implement-(void) DrawRect: (CGRect) Rect method, and then in this method

3. Get the graphical context associated with the current view

4. Draw the appropriate graphic content

5. Render all rendered content to the view using the graphical context

Why implement DrawRect: How can I draw to a view?

Because the graphics context associated with the view can be obtained in the DrawRect: method

After you get the context in the DrawRect: method, you can draw something to the view

There is a layer property inside the view, DrawRect: A layer Graphics Context is obtained in the method, so the drawing is actually drawn to the view layer.

View is able to show things entirely because of its inner layer

DrawRect: When is the method called?

1. When the view is displayed on the screen for the first time (it is added to the UIWindow)

2. Call the view's Setneedsdisplay or Setneedsdisplayinrect: when

QUARTZ2D Study Summary

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.