YYKit Prequel

2017-09-01  本文已影响46人  钱嘘嘘

一、Text Programming Guide for iOS

metrics

1. UIKit Framework

<1> Displaying Text Content in iOS

<2> Typographical Concepts

kerning, ligatures, line breaking, justification.

<3> Managing Text Fields and Text Views

用`enum`设置`UIView`的`tag`,来区分同类控件

2. Edit Text

<1> Managing the Keyboard 

-- contentInsets + scrollRectToVisible

-- superview+=kbSize.height + setContentOffset

3. Draw and Manage Text Directly

<1> Using Text Kit to Draw and Manage Text  --  Text Kit

Text Kit is a set of classes and protocols that provide high-quality typographical services which enable apps to store, lay out, and display text with all the characteristics of fine typesetting, such as kerning, ligatures, line breaking, and justification.

Text Kit handles three kinds of text attributes: character attributes, paragraph attributes, and document attributes.

i. NSTextStorage: NSAttributedString

ii. NSParagraphStyle

iii. UIFont + UIFontDescriptor + Font Features  --  should not cache font objects __ you can cache a font descriptor + the feature type identifiers and feature selector identifiers.

iv. Font Metrics

v. NSLayoutManager  --  glyph generation and glyph layout

vi. Line Fragment Rectangles

vii. Specifying Exclusion Paths

viii. Specifying Multipage and Multicolumn Layouts

<2> Lower Level Text-Handling Technologies

i. Core Text

Core Text Layout Opaque Types

Core Text Font Opaque Types  --  CTFont,CTFontDescriptor,CTFontCollection

ii. Core Graphics Text Drawing  --  so low-level

iii. Foundation-Level Regular Expressions  --  NSString + (http://userguide.icu-project.org/strings/regexp

iv. Simple Text Input  --  UIKeyInput (insert and delete characters) + UITextInputTraits + UIStringDrawing

v. Communicating with the Text Input System  --  UITextInput

vi. A Guided Tour of a UITextInput Implementation

Subclasses of UITextPosition and UITextRange + Inserting and Deleting Text

Returning and Replacing Text by Range + Maintaining Selected and Marked Text Ranges

Frequently Called UITextInput Methods + Returning Rectangles + Hit Testing

Informing the Text Input Delegate of Changes  --  (the text input system automatically assigns a delegate object to this property at runtime)

4. Input and Editing of Data

<1> Copy, Cut, and Paste Operations

UIPasteboard + UIMenuController + (UIResponder - canPerformAction:withSender:) + UIResponderStandardEditActions

you may use pasteboards to transfer data between apps using custom URL schemes instead of copy, cut, and paste commands; see Updating Your Info.plist Settings for information about this technique.

i. Named Pasteboards + Pasteboard Persistence,Owner,Items,Representations and UTIs

system pasteboards + app pasteboards

UIPasteboardNameGeneral + UIPasteboardNameFind

ii. Copying and Cutting the Selection

UIResponderStandardEditActions

binary data + more other representations + pasteboard object + UTI + setData:forPasteboardType: + if cut data model

iii. Pasting the Selection

pasteboard object + containsPasteboardTypes: + dataForPasteboardType: + data model + Display

<2> Displaying and Managing the Edit Menu

i. Managing the Selection and the Edit Menu

global + setTargetRect:inView: + setMenuVisible:animated:

canPerformAction:withSender:  --  Conditionally enabling menu

ii. Adding Custom Items to the Edit Menu

UIMenuItem

<3> Custom Views for Data Input  --  keyboard

i. Input Views and Input Accessory Views

UIResponder - inputView + inputAccessoryView

ii. Playing Input Clicks

UIInputViewAudioFeedback + playInputClick



二、Core Text Programming Guide

1. Core Text Lays Out Text

<1> Core Text Overview

you must have a Quartz graphic context to render Core Text–generated glyphs

i. Core Text Opaque Types

ii. Font Objects  --  CTFontRef

iii. Font Descriptors  --  CTFontDescriptor

iv. Font Collections  --  CTFontCollection

<2> Common Text Layout Operations

i. Laying Out a Paragraph  --  create and initialize the context, path, and string - CTFramesetterRef + CTFrameRef

ii. Simple Text Label

CFDictionaryRef -> CFAttributedStringRef -> CTLineRef

iii. Columnar Layout

createColumnsWithColumnCount (columnPathsArr) + CTFrameDraw

iv. Manual Line Breaking

CTTypesetterRef + CTLineRef + CTLineGetPenOffsetForFlush(center a line)

v. Applying a Paragraph Style

CTParagraphStyleSetting + CTParagraphStyleRef

vi. Displaying Text in a Non-rectangular Region

2. Manage Fonts With Core Text

<1> Common Font Operations

i. Creating Font Descriptors + ii. Creating a Font from a Font Descriptor + iii. Creating Related Fonts

iv. Serializing a Font + v. Creating a Font from Serialized Data + vi. Changing Kerning

vii. Getting Glyphs for Characters

上一篇下一篇

猜你喜欢

热点阅读