CoreText learning notes and coretext learning notes
1. Coretext and UIWebView
Compared with the Implementation Based on CoreText and UIWebView, the former has the following benefits:
- CoreText occupies less memory and UIWebView occupies more memory.
- CoreText can accurately obtain the height of the displayed content before rendering the interface (as long as a CTFrame is available), and UIWebView can only obtain the height of the displayed content after rendering the content, to get the height of the content (and javascript code is also required)
- The CTFrame of CoreText can be rendered in the background thread, and the content of UIWebView can only be rendered in the main thread (UI thread.
- Based on CoreText, you can achieve better native interaction and more delicate interaction effects. The interaction effects of UIWebView are all implemented using javascript, and some slow interaction effects exist. For example, in UIWebView, a simple button cannot achieve real-time and fine-grained native button pressing.
Of course, CoreText-based solutions also have some disadvantages:
- The content rendered by CoreText cannot be copied as conveniently as that of UIWebView.
- For CoreText-based formatting, you need to process the image formatting logic and support link clicking.
Core Text object model
You have created a CTFramesetter to associate it with your NSAttributedString. The CTTypesetter instance is automatically created to manage your fonts. Next, use CTFramesetter to create one or more frames for text rendering.
When you create a frame, you specify a text range used in the rectangle of the frame. Core Text automatically creates a CTLine for each line of Text (note here) and creates multiple CTRun Text segments. The Text in each CTRun has the same format.
For example, Core Text may create a CTRun for several red words, other CTRun may include plain Text, and some CTRun may be bold. Again, you should not directly create CTRun instances by yourself. Core Text uses the NSAttributedString attributes you provide to create CTRun instances.
Each CTRun object can use different attributes, so you can precisely control more attributes such as the padding, hyphen, width, and height.
2. Drawing with Core Text
In general, Core Text does not have the ability to draw images. However, because it is a layout engine, what it can do is to reserve a space for you to draw images in it. At the same time, because your code already has the drawRect: method, it is easy to draw an image. Let's take a look at how a reserved space works in the text: Do you still remember that all text blocks are actually CTRun instances? You only need to set the delegate for the CTRun, and the delegate object will be responsible for notifying the CTRun's rising space, descent space and width to the Core Text. For example:
To present an image, you need to clearly know which frame the image will be displayed in the application. To locate this origin, we need a series of values:
- ContentOffset
- Frame Offset of CTView (frameXOffset, frameYOffset)
- The origin coordinate of the CTLine (the CTLine may be offset at the beginning of the paragraph)
- The last is the distance between the CTRun and CTLine origins.
Iii. character & glyph
A character is the smallest unit of written language that carries meaning, e.g. uppercase.
A glyph is a concrete form of a character. in our previous example, the character uppercase A can be drawn with a different size or a different stroke thickness. it can lean or be vertical, and have certain optional variations in form. the following figure represents glyphs of the character:
Note that characters and glyphs do not have a one-to-one corresponsor. in some cases, a character may be represented by multiple glyphs, such as an é, which may be an e glyph combined with an acute accent glyph' (accent ). in other cases, a single glyph may represent multiple characters, as in the case of a ligature, or joined letter. the following figure represents the ligature case:
A glyph-run is a set of consecutive glyphs sharing the same attributes and direction.
Refer:
1. http://www.dapps.net/dev/iphone/how-to-create-a-simple-magazine-app-with-core-text.html
2. http://weblog.invasivecode.com/core-text
For Study Notes
How to write Chinese notes
How to write Chinese notes
As the saying goes, "It's better to remember with ink", and "it's better to write your mind over a thousand times ". The teacher makes the class clearer in class. If the students do not remember it, they will forget it later. Note-taking is an extension of memory for future review and searching. The more advanced the learning, the more important it is to remember. Students take notes while attending lectures in the classroom. They can be in the best learning status of brainstorming, hands-on, and ears. They can suppress the "thoughts" and make their attention highly concentrated, improve efficiency, and deepen their impressions. Note Taking can also speed up writing and save time. Teachers should teach students to take Chinese notes from the upper grades of primary school. When I was a child, students learned to take Chinese notes, which laid the foundation for future Chinese learning and other subjects, formed self-learning ability, and formed good study habits, and can be used for life.
How do I take Chinese notes? Students should write their preview notes, class notes, and some Chinese homework together in one book, collectively referred to as "Chinese notes ". In this way, the complexity can be simplified, which not only reduces the Learning Burden of students, but also reduces the burden of teachers' correction. There are both checks on students' previewing, feedback on classroom teaching, and acceptance of basic knowledge. The teacher can correct the Chinese notes and receive the effect of "three in one fell swoop.
It is best to use a 16-open "course preparation notebook" in a Chinese notebook. Draw two straight lines on both sides of each page and divide them into three parts. One copy on the left is about two characters in width, which is used for project recording and serves as a Directory Index. the other copy on the right is about one inch in width and is used for remarks. This part is used flexibly by students, note some difficult questions, your own comments, feelings, and learning methods. The content of this part is inconsistent. the widest and most important one in the middle is, the learning content is recorded in this section.
After the preparation is complete, the next step is how to remember. You can take Chinese notes in three stages:
1. Preparations before class
Before learning a new course, students should preview the course, and record the content learned in the course and the problems they cannot solve in the middle and right parts of the Chinese notes respectively. The words and words that can be solved through the tool book are all completed at this time, which is one of the three parts of the Chinese notes.
2. Lecture Notes
This is the most important part in Chinese notes. In a Chinese class, students need to take notes while taking lectures, record the content of the new course in the middle column, and record the content that can be corrected due to inaccurate understanding in the preview in the remarks column on the right. At this time, there are two points to note: first, students can't talk about it. After the course, the students write the content they want to remember on the blackboard; second, the students cannot write down all the words the teacher says. On the basis of understanding, they should listen and think, sum up the key points, and generalize them into key sentences or words, then write it to the Chinese notes, as long as the meaning is correct. When starting the training, the teacher should say slowly what needs to be recorded, and repeat the long sentences and important points one or two times. Keywords, new words, Homophone Words, and easy-to-mix and easy-to-error words to be remembered. Teachers should blackboard writing to prevent students' mistakes.
3. consolidation after class
After a Chinese lesson, students need to take notes. The questions that have been solved in the text should be followed up, and the missing parts should be supplemented. It is best to remember them in summary, the good words and good sentences in the article can also be excerpted based on interest. After the course is organized and modified, the students' understanding of the content is deepened and their understanding is improved. The content to be recorded after class also includes some exercise questions after the course, such as the words to be copied, the words to be interpreted, the words to be interpreted, the meanings of the key sentences to be understood, and the brackets, sentences. In this way, the content of each lesson is concentrated on the Chinese notes, so that the knowledge can be easily classified for review and search; students can save the additional effort to write their homework, and the Chinese notes can be handed over as homework; when correcting Chinese notes, the teacher not only accepted the basic knowledge of the course, but also checked the students' preview and lectures. During the training process, teachers should focus on students, solicit Students' Opinions, constantly improve their practices, and do not insist on consistency in form and content. This can cultivate students' creative and divergent thinking abilities.
Chinese classroom learning and guiding strategies
What is study notes?
What should I do with study notes? All day long, I listened to the teacher saying that I should take notes. What is learning notes? In fact, it is also very simple, that is, the key and difficulty of your study in class, the content that the teacher repeatedly reminds you of, the discipline knowledge that you think is valuable, and your learning skills, etc, of course, it is best to remember your questions and puzzles at the end, which not only helps the teacher understand your learning situation, but also helps you find your own shortcomings in the future. Do it with your heart and you will surely get something !!