From 7b02207537d35bfa1714bf8beafc921f717d100a Mon Sep 17 00:00:00 2001 From: 单军华 Date: Wed, 11 Jul 2018 10:47:42 +0800 Subject: [PATCH] 首次上传 --- screendisplay/Pods/YYText/README.md | 1095 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1,095 insertions(+), 0 deletions(-) diff --git a/screendisplay/Pods/YYText/README.md b/screendisplay/Pods/YYText/README.md new file mode 100755 index 0000000..062aa55 --- /dev/null +++ b/screendisplay/Pods/YYText/README.md @@ -0,0 +1,1095 @@ +YYText +============== +[](https://raw.githubusercontent.com/ibireme/YYText/master/LICENSE) +[](https://github.com/Carthage/Carthage) +[](http://cocoapods.org/?q= YYText) +[](http://cocoapods.org/?q= YYText) +[](https://www.apple.com/nl/ios/) +[](https://travis-ci.org/ibireme/YYText) + +Powerful text framework for iOS to display and edit rich text.<br/> +(It's a component of [YYKit](https://github.com/ibireme/YYKit)) + + +Features +============== + +- UILabel and UITextView API compatible +- High performance asynchronous text layout and rendering +- Extended CoreText attributes with more text effects +- Text attachments with UIImage, UIView and CALayer +- Custom highlight text range to allow user interact with +- Text parser support (built in markdown/emoticon parser) +- Text container path and exclusion paths support +- Vertical form layout support (for CJK text) +- Image and attributed text copy/paste support +- Attributed text placeholder support +- Custom keyboard view support +- Undo and redo control +- Attributed text archiver and unarchiver support +- Multi-language and VoiceOver support +- Interface Builder support +- Fully documented + + +Architecture +============== +YYText vs TextKit + +<img src="https://raw.github.com/ibireme/YYText/master/Attributes/architecture.png" width="400"> + + +Text Attributes +============== + +### YYText supported attributes +<table> + <thead> + <tr> + <th>Demo</th> + <th>Attribute Name</th> + <th>Class</th> + </tr> + </thead> + <tbody> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextAttachment.gif" width="200"></td> + <td>TextAttachment</td> + <td>YYTextAttachment</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextHighlight.gif" width="200"></td> + <td>TextHighlight</td> + <td>YYTextHighlight</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBinding.gif" width="200"></td> + <td>TextBinding</td> + <td>YYTextBinding</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextShadow.png" width="200"></td> + <td>TextShadow<br/>TextInnerShadow</td> + <td>YYTextShadow</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBorder.png" width="200"></td> + <td>TextBorder</td> + <td>YYTextBorder</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBackgroundBorder.png" width="200"></td> + <td>TextBackgroundBorder</td> + <td>YYTextBorder</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBlockBorder.png" width="200"></td> + <td>TextBlockBorder</td> + <td>YYTextBorder</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Obliqueness.png" width="200"></td> + <td>TextGlyphTransform</td> + <td> NSValue(CGAffineTransform)</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Underline.png" width="200"></td> + <td>TextUnderline</td> + <td>YYTextDecoration</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Strikethrough.png" width="200"></td> + <td>TextStrickthrough</td> + <td>YYTextDecoration</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBackedString.png" width="200"></td> + <td>TextBackedString</td> + <td>YYTextBackedString</td> + </tr> + </tbody> +</table> + +###CoreText attributes which is supported by YYText +<table> + <thead> + <tr> + <th>Demo</th> + <th>Attribute Name</th> + <th>Class</th> + </tr> + </thead> + <tbody> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Font.png" width="200"></td> + <td> Font </td> + <td>UIFont(CTFontRef)</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Kern.png" width="200"></td> + <td> Kern </td> + <td>NSNumber</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Stroke.png" width="200"></td> + <td> StrokeWidth </td> + <td> NSNumber </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/StrokeColor.png" width="200"></td> + <td> StrokeColor </td> + <td> CGColorRef </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Shadow.png" width="200"></td> + <td> Shadow </td> + <td> NSShadow </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Ligature.png" width="200"></td> + <td> Ligature </td> + <td> NSNumber </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/VerticalForms.png" width="200"></td> + <td> VerticalGlyphForm </td> + <td> NSNumber(BOOL) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/WriteDirection.png" width="200"></td> + <td> WritingDirection </td> + <td> NSArray(NSNumber) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/RunDelegate.png" width="200"></td> + <td> RunDelegate </td> + <td> CTRunDelegateRef </td> + </tr> + + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/Alignment.png" width="200"></td> + <td> TextAlignment </td> + <td> NSParagraphStyle <br/>(NSTextAlignment) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/LineBreakMode.png" width="200"></td> + <td> LineBreakMode </td> + <td> NSParagraphStyle <br/>(NSLineBreakMode) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/LineSpacing.png" width="200"></td> + <td> LineSpacing </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/ParagraphSpacing.png" width="200"></td> + <td> ParagraphSpacing <br/> ParagraphSpacingBefore </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/FirstLineHeadIndent.png" width="200"></td> + <td> FirstLineHeadIndent </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/HeadIndent.png" width="200"></td> + <td> HeadIndent </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/TailIndent.png" width="200"></td> + <td> TailIndent </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/MinimumLineHeight.png" width="200"></td> + <td> MinimumLineHeight </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/MaximumLineHeight.png" width="200"></td> + <td> MaximumLineHeight </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/LineHeightMultiple.png" width="200"></td> + <td> LineHeightMultiple </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/BaseWritingDirection.png" width="200"></td> + <td> BaseWritingDirection </td> + <td> NSParagraphStyle <br/>(NSWritingDirection) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/Tab.png" width="200"></td> + <td> DefaultTabInterval <br/> TabStops </td> + <td> NSParagraphStyle <br/>CGFloat/NSArray(NSTextTab)</td> + </tr> + </tbody> +</table> + + +Usage +============== + +### Basic + // YYLabel (similar to UILabel) + YYLabel *label = [YYLabel new]; + label.frame = ... + label.font = ... + label.textColor = ... + label.textAlignment = ... + label.lineBreakMode = ... + label.numberOfLines = ... + label.text = ... + + // YYTextView (similar to UITextView) + YYTextView *textView = [YYTextView new]; + textView.frame = ... + textView.font = ... + textView.textColor = ... + textView.dataDetectorTypes = ... + textView.placeHolderText = ... + textView.placeHolderTextColor = ... + textView.delegate = ... + + +### Attributed text + + // 1. Create an attributed string. + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"Some Text, blabla..."]; + + // 2. Set attributes to text, you can use almost all CoreText attributes. + text.yy_font = [UIFont boldSystemFontOfSize:30]; + text.yy_color = [UIColor blueColor]; + [text yy_setColor:[UIColor redColor] range:NSMakeRange(0, 4)]; + text.yy_lineSpacing = 10; + + // 3. Set to YYLabel or YYTextView. + YYLabel *label = [YYLabel new]; + label.frame = ... + label.attributedString = text; + + YYTextView *textView = [YYTextView new]; + textView.frame = ... + textView.attributedString = text; + +### Text highlight + +You can use some convenience methods to set text highlight: + + [text yy_setTextHighlightRange:range + color:[UIColor blueColor] + backgroundColor:[UIColor grayColor] + tapAction:^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect){ + NSLog(@"tap text range:..."); + }]; + +Or set the text highlight with your custom config: + + // 1. Create a 'highlight' attribute for text. + YYTextBorder *border = [YYTextBorder borderWithFillColor:[UIColor grayColor] cornerRadius:3]; + + YYTextHighlight *highlight = [YYTextHighlight new]; + [highlight setColor:[UIColor whiteColor]]; + [highlight setBackgroundBorder:highlightBorder]; + highlight.tapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) { + NSLog(@"tap text range:..."); + // you can also set the action handler to YYLabel or YYTextView. + }; + + // 2. Add 'highlight' attribute to a range of text. + [attributedText yy_setTextHighlight:highlight range:highlightRange]; + + // 3. Set text to label or text view. + YYLabel *label = ... + label.attributedText = attributedText + + YYTextView *textView = ... + textView.attributedText = ... + + // 4. Receive user interactive action. + label.highlightTapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) { + NSLog(@"tap text range:..."); + }; + label.highlightLongPressAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) { + NSLog(@"long press text range:..."); + }; + + @UITextViewDelegate + - (void)textView:(YYTextView *)textView didTapHighlight:(YYTextHighlight *)highlight inRange:(NSRange)characterRange rect:(CGRect)rect { + NSLog(@"tap text range:..."); + } + - (void)textView:(YYTextView *)textView didLongPressHighlight:(YYTextHighlight *)highlight inRange:(NSRange)characterRange rect:(CGRect)rect { + NSLog(@"long press text range:..."); + } + + +### Text attachments + + NSMutableAttributedString *text = [NSMutableAttributedString new]; + UIFont *font = [UIFont systemFontOfSize:16]; + NSMutableAttributedString *attachment = nil; + + // UIImage attachment + UIImage *image = [UIImage imageNamed:@"dribbble64_imageio"]; + attachment = [NSMutableAttributedString yy_attachmentStringWithContent:image contentMode:UIViewContentModeCenter attachmentSize:image.size alignToFont:font alignment:YYTextVerticalAlignmentCenter]; + [text appendAttributedString: attachment]; + + // UIView attachment + UISwitch *switcher = [UISwitch new]; + [switcher sizeToFit]; + attachment = [NSMutableAttributedString yy_attachmentStringWithContent:switcher contentMode:UIViewContentModeBottom attachmentSize:switcher.size alignToFont:font alignment:YYTextVerticalAlignmentCenter]; + [text appendAttributedString: attachment]; + + // CALayer attachment + CASharpLayer *layer = [CASharpLayer layer]; + layer.path = ... + attachment = [NSMutableAttributedString yy_attachmentStringWithContent:layer contentMode:UIViewContentModeBottom attachmentSize:switcher.size alignToFont:font alignment:YYTextVerticalAlignmentCenter]; + [text appendAttributedString: attachment]; + + +### Text layout calculation + + NSAttributedString *text = ... + CGSize size = CGSizeMake(100, CGFLOAT_MAX); + YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:size text:text]; + + // get text bounding + layout.textBoundingRect; // get bounding rect + layout.textBoundingSize; // get bounding size + + // query text layout + [layout lineIndexForPoint:CGPointMake(10,10)]; + [layout closestLineIndexForPoint:CGPointMake(10,10)]; + [layout closestPositionToPoint:CGPointMake(10,10)]; + [layout textRangeAtPoint:CGPointMake(10,10)]; + [layout rectForRange:[YYTextRange rangeWithRange:NSMakeRange(10,2)]]; + [layout selectionRectsForRange:[YYTextRange rangeWithRange:NSMakeRange(10,2)]]; + + // text layout display + YYLabel *label = [YYLabel new]; + label.size = layout.textBoundingSize; + label.textLayout = layout; + + +### Adjust text line position + + // Convenience methods: + // 1. Create a text line position modifier, implements `YYTextLinePositionModifier` protocol. + // 2. Set it to label or text view. + + YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new]; + modifier.fixedLineHeight = 24; + + YYLabel *label = [YYLabel new]; + label.linePositionModifier = modifier; + + // Fully control + YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new]; + modifier.fixedLineHeight = 24; + + YYTextContainer *container = [YYTextContainer new]; + container.size = CGSizeMake(100, CGFLOAT_MAX); + container.linePositionModifier = modifier; + + YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text]; + YYLabel *label = [YYLabel new]; + label.size = layout.textBoundingSize; + label.textLayout = layout; + + +### Asynchronous layout and rendering + + // If you have performance issues, + // you may enable the asynchronous display mode. + YYLabel *label = ... + label.displaysAsynchronously = YES; + + // If you want to get the highest performance, you should do + // text layout with `YYTextLayout` class in background thread. + YYLabel *label = [YYLabel new]; + label.displaysAsynchronously = YES; + label.ignoreCommonProperties = YES; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + // Create attributed string. + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"Some Text"]; + text.yy_font = [UIFont systemFontOfSize:16]; + text.yy_color = [UIColor grayColor]; + [text yy_setColor:[UIColor redColor] range:NSMakeRange(0, 4)]; + + // Create text container + YYTextContainer *container = [YYTextContainer new]; + container.size = CGSizeMake(100, CGFLOAT_MAX); + container.maximumNumberOfRows = 0; + + // Generate a text layout. + YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text]; + + dispatch_async(dispatch_get_main_queue(), ^{ + label.size = layout.textBoundingSize; + label.textLayout = layout; + }); + }); + + +### Text container control + + YYLabel *label = ... + label.textContainerPath = [UIBezierPath bezierPathWith...]; + label.exclusionPaths = @[[UIBezierPath bezierPathWith...];,...]; + label.textContainerInset = UIEdgeInsetsMake(...); + label.verticalForm = YES/NO; + + YYTextView *textView = ... + textView.exclusionPaths = @[[UIBezierPath bezierPathWith...];,...]; + textView.textContainerInset = UIEdgeInsetsMake(...); + textView.verticalForm = YES/NO; + +### Text parser + // 1. Create a text parser + + YYTextSimpleEmoticonParser *parser = [YYTextSimpleEmoticonParser new]; + NSMutableDictionary *mapper = [NSMutableDictionary new]; + mapper[@":smile:"] = [UIImage imageNamed:@"smile.png"]; + mapper[@":cool:"] = [UIImage imageNamed:@"cool.png"]; + mapper[@":cry:"] = [UIImage imageNamed:@"cry.png"]; + mapper[@":wink:"] = [UIImage imageNamed:@"wink.png"]; + parser.emoticonMapper = mapper; + + YYTextSimpleMarkdownParser *parser = [YYTextSimpleMarkdownParser new]; + [parser setColorWithDarkTheme]; + + MyCustomParser *parser = ... // custom parser + + // 2. Attach parser to label or text view + YYLabel *label = ... + label.textParser = parser; + + YYTextView *textView = ... + textView.textParser = parser; + +### Debug + + // Set a shared debug option to show text layout result. + YYTextDebugOption *debugOptions = [YYTextDebugOption new]; + debugOptions.baselineColor = [UIColor redColor]; + debugOptions.CTFrameBorderColor = [UIColor redColor]; + debugOptions.CTLineFillColor = [UIColor colorWithRed:0.000 green:0.463 blue:1.000 alpha:0.180]; + debugOptions.CGGlyphBorderColor = [UIColor colorWithRed:1.000 green:0.524 blue:0.000 alpha:0.200]; + [YYTextDebugOption setSharedDebugOption:debugOptions]; + + +### More examples +See `Demo/YYTextDemo.xcodeproj` for more examples: + +<img src="https://raw.github.com/ibireme/YYText/master/Demo/DemoSnapshot/text_path.gif" width="320"> +<img src="https://raw.github.com/ibireme/YYText/master/Demo/DemoSnapshot/text_markdown.gif" width="320"> +<br/> <br/> +<img src="https://raw.github.com/ibireme/YYText/master/Demo/DemoSnapshot/text_vertical.gif" width="320"> +<img src="https://raw.github.com/ibireme/YYText/master/Demo/DemoSnapshot/text_paste.gif" width="320"> + + +Installation +============== + +### CocoaPods + +1. Add `pod 'YYText'` to your Podfile. +2. Run `pod install` or `pod update`. +3. Import \<YYText/YYText.h\>. + + +### Carthage + +1. Add `github "ibireme/YYText"` to your Cartfile. +2. Run `carthage update --platform ios` and add the framework to your project. +3. Import \<YYText/YYText.h\>. + + +### Manually + +1. Download all the files in the `YYText` subdirectory. +2. Add the source files to your Xcode project. +3. Link with required frameworks: + * UIKit + * CoreFoundation + * CoreText + * QuartzCore + * Accelerate + * MobileCoreServices +4. Import `YYText.h`. + + +### Notice +You may add [YYImage](https://github.com/ibireme/YYImage) or [YYWebImage](https://github.com/ibireme/YYWebImage) to your project if you want to support animated image (GIF/APNG/WebP). + + +Documentation +============== +Full API documentation is available on [CocoaDocs](http://cocoadocs.org/docsets/YYText/).<br/> +You can also install documentation locally using [appledoc](https://github.com/tomaz/appledoc). + + +Requirements +============== +This library requires `iOS 6.0+` and `Xcode 7.0+`. + + +License +============== +YYText is released under the MIT license. See LICENSE file for details. + + +<br/><br/> +--- +������������ +============== +��������������� iOS ���������������������������������<br/> +(������������ [YYKit](https://github.com/ibireme/YYKit) ������������) + + +������ +============== +- API ������ UILabel ��� UITextView +- ��������������������������������������� +- ��������� CoreText ������������������������������������ +- ������ UIImage���UIView���CALayer ������������������������ +- ��������������������������������������������������������������� +- ��������������������������� (��������������� Markdown/������������) +- ������������������������������������������������������ +- ��������������������������������������������������������������� +- ��������������������������������������� +- ������������������������������������������ +- ��������������������������� +- ������������������������������ +- ������������������������������������������ +- ������������������������ VoiceOver +- ������ Interface Builder +- ������������������������������ + + +������ +============== +YYText ��� TextKit ������������ + +<img src="https://raw.github.com/ibireme/YYText/master/Attributes/architecture.png" width="400"> + + +������������ +============== + +### YYText ��������������������� +<table> + <thead> + <tr> + <th>Demo</th> + <th>Attribute Name</th> + <th>Class</th> + </tr> + </thead> + <tbody> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextAttachment.gif" width="200"></td> + <td>TextAttachment</td> + <td>YYTextAttachment</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextHighlight.gif" width="200"></td> + <td>TextHighlight</td> + <td>YYTextHighlight</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBinding.gif" width="200"></td> + <td>TextBinding</td> + <td>YYTextBinding</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextShadow.png" width="200"></td> + <td>TextShadow<br/>TextInnerShadow</td> + <td>YYTextShadow</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBorder.png" width="200"></td> + <td>TextBorder</td> + <td>YYTextBorder</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBackgroundBorder.png" width="200"></td> + <td>TextBackgroundBorder</td> + <td>YYTextBorder</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBlockBorder.png" width="200"></td> + <td>TextBlockBorder</td> + <td>YYTextBorder</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Obliqueness.png" width="200"></td> + <td>TextGlyphTransform</td> + <td> NSValue(CGAffineTransform)</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Underline.png" width="200"></td> + <td>TextUnderline</td> + <td>YYTextDecoration</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Strikethrough.png" width="200"></td> + <td>TextStrickthrough</td> + <td>YYTextDecoration</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/YYText Extended/YYTextBackedString.png" width="200"></td> + <td>TextBackedString</td> + <td>YYTextBackedString</td> + </tr> + </tbody> +</table> + +###YYText ��������� CoreText ������ +<table> + <thead> + <tr> + <th>Demo</th> + <th>Attribute Name</th> + <th>Class</th> + </tr> + </thead> + <tbody> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Font.png" width="200"></td> + <td> Font </td> + <td>UIFont(CTFontRef)</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Kern.png" width="200"></td> + <td> Kern </td> + <td>NSNumber</td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Stroke.png" width="200"></td> + <td> StrokeWidth </td> + <td> NSNumber </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/StrokeColor.png" width="200"></td> + <td> StrokeColor </td> + <td> CGColorRef </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Shadow.png" width="200"></td> + <td> Shadow </td> + <td> NSShadow </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Ligature.png" width="200"></td> + <td> Ligature </td> + <td> NSNumber </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/VerticalForms.png" width="200"></td> + <td> VerticalGlyphForm </td> + <td> NSNumber(BOOL) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/WriteDirection.png" width="200"></td> + <td> WritingDirection </td> + <td> NSArray(NSNumber) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/RunDelegate.png" width="200"></td> + <td> RunDelegate </td> + <td> CTRunDelegateRef </td> + </tr> + + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/Alignment.png" width="200"></td> + <td> TextAlignment </td> + <td> NSParagraphStyle <br/>(NSTextAlignment) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/LineBreakMode.png" width="200"></td> + <td> LineBreakMode </td> + <td> NSParagraphStyle <br/>(NSLineBreakMode) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/LineSpacing.png" width="200"></td> + <td> LineSpacing </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/ParagraphSpacing.png" width="200"></td> + <td> ParagraphSpacing <br/> ParagraphSpacingBefore </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/FirstLineHeadIndent.png" width="200"></td> + <td> FirstLineHeadIndent </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/HeadIndent.png" width="200"></td> + <td> HeadIndent </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/TailIndent.png" width="200"></td> + <td> TailIndent </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/MinimumLineHeight.png" width="200"></td> + <td> MinimumLineHeight </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/MaximumLineHeight.png" width="200"></td> + <td> MaximumLineHeight </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/LineHeightMultiple.png" width="200"></td> + <td> LineHeightMultiple </td> + <td> NSParagraphStyle <br/>(CGFloat) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/BaseWritingDirection.png" width="200"></td> + <td> BaseWritingDirection </td> + <td> NSParagraphStyle <br/>(NSWritingDirection) </td> + </tr> + <tr> + <td><img src="https://raw.github.com/ibireme/YYText/master/Attributes/CoreText and TextKit/Paragraph/Tab.png" width="200"></td> + <td> DefaultTabInterval <br/> TabStops </td> + <td> NSParagraphStyle <br/>CGFloat/NSArray(NSTextTab)</td> + </tr> + </tbody> +</table> + + +������ +============== + +### ������������ + // YYLabel (��� UILabel ������������) + YYLabel *label = [YYLabel new]; + label.frame = ... + label.font = ... + label.textColor = ... + label.textAlignment = ... + label.lineBreakMode = ... + label.numberOfLines = ... + label.text = ... + + // YYTextView (��� UITextView ������������) + YYTextView *textView = [YYTextView new]; + textView.frame = ... + textView.font = ... + textView.textColor = ... + textView.dataDetectorTypes = ... + textView.placeHolderText = ... + textView.placeHolderTextColor = ... + textView.delegate = ... + + +### ������������ + + // 1. ������������������������ + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"Some Text, blabla..."]; + + // 2. ��������������������� + text.yy_font = [UIFont boldSystemFontOfSize:30]; + text.yy_color = [UIColor blueColor]; + [text yy_setColor:[UIColor redColor] range:NSMakeRange(0, 4)]; + text.yy_lineSpacing = 10; + + // 3. ��������� YYLabel ��� YYTextView + YYLabel *label = [YYLabel new]; + label.frame = ... + label.attributedString = text; + + YYTextView *textView = [YYTextView new]; + textView.frame = ... + textView.attributedString = text; + + +### ������������ + +������������������������������������������������������������������������ + + [text yy_setTextHighlightRange:range + color:[UIColor blueColor] + backgroundColor:[UIColor grayColor] + tapAction:^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect){ + NSLog(@"tap text range:..."); + }]; + +������������������������������������������������������������ + + // 1. ������������"������"������������������������������������������������������"������"��������������������������������� + YYTextBorder *border = [YYTextBorder borderWithFillColor:[UIColor grayColor] cornerRadius:3]; + + YYTextHighlight *highlight = [YYTextHighlight new]; + [highlight setColor:[UIColor whiteColor]]; + [highlight setBackgroundBorder:highlightBorder]; + highlight.tapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) { + NSLog(@"tap text range:..."); + // ��������������������������������� YYLabel ��� YYTextView ������������ + }; + + // 2. ���"������"��������������������������������� + [attributedText yy_setTextHighlight:highlight range:highlightRange]; + + // 3. ������������������������ YYLabel ��� YYTextView + YYLabel *label = ... + label.attributedText = attributedText + + YYTextView *textView = ... + textView.attributedText = ... + + // 4. ������������������ + label.highlightTapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) { + NSLog(@"tap text range:..."); + }; + label.highlightLongPressAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) { + NSLog(@"long press text range:..."); + }; + + @UITextViewDelegate + - (void)textView:(YYTextView *)textView didTapHighlight:(YYTextHighlight *)highlight inRange:(NSRange)characterRange rect:(CGRect)rect { + NSLog(@"tap text range:..."); + } + - (void)textView:(YYTextView *)textView didLongPressHighlight:(YYTextHighlight *)highlight inRange:(NSRange)characterRange rect:(CGRect)rect { + NSLog(@"long press text range:..."); + } + + +### ������������ + + NSMutableAttributedString *text = [NSMutableAttributedString new]; + UIFont *font = [UIFont systemFontOfSize:16]; + NSMutableAttributedString *attachment = nil; + + // ������ UIImage + UIImage *image = [UIImage imageNamed:@"dribbble64_imageio"]; + attachment = [NSMutableAttributedString yy_attachmentStringWithContent:image contentMode:UIViewContentModeCenter attachmentSize:image.size alignToFont:font alignment:YYTextVerticalAlignmentCenter]; + [text appendAttributedString: attachment]; + + // ������ UIView + UISwitch *switcher = [UISwitch new]; + [switcher sizeToFit]; + attachment = [NSMutableAttributedString yy_attachmentStringWithContent:switcher contentMode:UIViewContentModeBottom attachmentSize:switcher.size alignToFont:font alignment:YYTextVerticalAlignmentCenter]; + [text appendAttributedString: attachment]; + + // ������ CALayer + CASharpLayer *layer = [CASharpLayer layer]; + layer.path = ... + attachment = [NSMutableAttributedString yy_attachmentStringWithContent:layer contentMode:UIViewContentModeBottom attachmentSize:switcher.size alignToFont:font alignment:YYTextVerticalAlignmentCenter]; + [text appendAttributedString: attachment]; + + +### ������������������ + + NSAttributedString *text = ... + CGSize size = CGSizeMake(100, CGFLOAT_MAX); + YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:size text:text]; + + // ��������������������������������� + layout.textBoundingRect; // get bounding rect + layout.textBoundingSize; // get bounding size + + // ������������������������ + [layout lineIndexForPoint:CGPointMake(10,10)]; + [layout closestLineIndexForPoint:CGPointMake(10,10)]; + [layout closestPositionToPoint:CGPointMake(10,10)]; + [layout textRangeAtPoint:CGPointMake(10,10)]; + [layout rectForRange:[YYTextRange rangeWithRange:NSMakeRange(10,2)]]; + [layout selectionRectsForRange:[YYTextRange rangeWithRange:NSMakeRange(10,2)]]; + + // ������������������������ + YYLabel *label = [YYLabel new]; + label.size = layout.textBoundingSize; + label.textLayout = layout; + + +### ��������������������� + + // ������������������������Emoji ������������������������������������������������������������������������������ + // ������������������������������������������������������������������������������������������������������������������������������������������ + + // ���������������: + // 1. ��������������������������������������������� `YYTextLinePositionModifier` ��������� + // 2. ��������� Label ��� TextView��� + + YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new]; + modifier.fixedLineHeight = 24; + + YYLabel *label = [YYLabel new]; + label.linePositionModifier = modifier; + + // ������������: + YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new]; + modifier.fixedLineHeight = 24; + + YYTextContainer *container = [YYTextContainer new]; + container.size = CGSizeMake(100, CGFLOAT_MAX); + container.linePositionModifier = modifier; + + YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text]; + YYLabel *label = [YYLabel new]; + label.size = layout.textBoundingSize; + label.textLayout = layout; + + +### ��������������������� + + // ��������������������������������������������������������������������������������� + YYLabel *label = ... + label.displaysAsynchronously = YES; + + // ��������������������������������������������������������������� `YYTextLayout` ������������������ + YYLabel *label = [YYLabel new]; + label.displaysAsynchronously = YES; //������������������ + label.ignoreCommonProperties = YES; //������������ textLayout ��������������������� + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + // ��������������������� + NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"Some Text"]; + text.yy_font = [UIFont systemFontOfSize:16]; + text.yy_color = [UIColor grayColor]; + [text yy_setColor:[UIColor redColor] range:NSMakeRange(0, 4)]; + + // ������������������ + YYTextContainer *container = [YYTextContainer new]; + container.size = CGSizeMake(100, CGFLOAT_MAX); + container.maximumNumberOfRows = 0; + + // ������������������ + YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text]; + + dispatch_async(dispatch_get_main_queue(), ^{ + label.size = layout.textBoundingSize; + label.textLayout = layout; + }); + }); + + +### ������������������ + + YYLabel *label = ... + label.textContainerPath = [UIBezierPath bezierPathWith...]; + label.exclusionPaths = @[[UIBezierPath bezierPathWith...];,...]; + label.textContainerInset = UIEdgeInsetsMake(...); + label.verticalForm = YES/NO; + + YYTextView *textView = ... + textView.exclusionPaths = @[[UIBezierPath bezierPathWith...];,...]; + textView.textContainerInset = UIEdgeInsetsMake(...); + textView.verticalForm = YES/NO; + + +### ������������ + // 1. ��������������������� + + // ��������������������������� + YYTextSimpleEmoticonParser *parser = [YYTextSimpleEmoticonParser new]; + NSMutableDictionary *mapper = [NSMutableDictionary new]; + mapper[@":smile:"] = [UIImage imageNamed:@"smile.png"]; + mapper[@":cool:"] = [UIImage imageNamed:@"cool.png"]; + mapper[@":cry:"] = [UIImage imageNamed:@"cry.png"]; + mapper[@":wink:"] = [UIImage imageNamed:@"wink.png"]; + parser.emoticonMapper = mapper; + + // ��������������� markdown ������ + YYTextSimpleMarkdownParser *parser = [YYTextSimpleMarkdownParser new]; + [parser setColorWithDarkTheme]; + + // ������ `YYTextParser` ��������������������������� + MyCustomParser *parser = ... + + // 2. ��������������������� YYLabel ��� YYTextView + YYLabel *label = ... + label.textParser = parser; + + YYTextView *textView = ... + textView.textParser = parser; + +### Debug + + // ��������������������� debug option ������������������������ + YYTextDebugOption *debugOptions = [YYTextDebugOption new]; + debugOptions.baselineColor = [UIColor redColor]; + debugOptions.CTFrameBorderColor = [UIColor redColor]; + debugOptions.CTLineFillColor = [UIColor colorWithRed:0.000 green:0.463 blue:1.000 alpha:0.180]; + debugOptions.CGGlyphBorderColor = [UIColor colorWithRed:1.000 green:0.524 blue:0.000 alpha:0.200]; + [YYTextDebugOption setSharedDebugOption:debugOptions]; + +### ������������ +������������������ `Demo/YYTextDemo.xcodeproj`: + +<img src="https://raw.github.com/ibireme/YYText/master/Demo/DemoSnapshot/text_path.gif" width="320"> +<img src="https://raw.github.com/ibireme/YYText/master/Demo/DemoSnapshot/text_markdown.gif" width="320"> +<br/> <br/> +<img src="https://raw.github.com/ibireme/YYText/master/Demo/DemoSnapshot/text_vertical.gif" width="320"> +<img src="https://raw.github.com/ibireme/YYText/master/Demo/DemoSnapshot/text_paste.gif" width="320"> + + +������ +============== + +### CocoaPods + +1. ��� Podfile ��������� `pod 'YYText'`��� +2. ������ `pod install` ��� `pod update`��� +3. ������ \<YYText/YYText.h\>��� + + +### Carthage + +1. ��� Cartfile ��������� `github "ibireme/YYText"`��� +2. ������ `carthage update --platform ios` ��������������� framework ������������������������ +3. ������ \<YYText/YYText.h\>��� + + +### ������������ + +1. ������ YYText ������������������������������ +2. ��� YYText ���������������������(������)������������������ +3. ������������ frameworks: + * UIKit + * CoreFoundation + * CoreText + * QuartzCore + * Accelerate + * MobileCoreServices +4. ������ `YYText.h`��� + + +### ������ +��������������� [YYImage](https://github.com/ibireme/YYImage) ��� [YYWebImage](https://github.com/ibireme/YYWebImage) ���������������������������������������(GIF/APNG/WebP)������������ + + +������ +============== +������������ [CocoaDocs](http://cocoadocs.org/docsets/YYText/) ������������ API ��������������������� [appledoc](https://github.com/tomaz/appledoc) ��������������������� + + +������������ +============== +��������������������� `iOS 6.0` ��� `Xcode 7.0`��� + + +������������ +============== +* YYText ��������������������� CoreText/TextKit ������������������ NSBackgroundColor���NSStrikethrough���NSUnderline���NSAttachment���NSLink ��������� YYText ������������������������������������������������������������������ +* YYTextView ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ +* ��������������������� exclusionPaths ������������������������������������������������������ +* ������������������������ textContainerPath��������������������������������������������������� RunDelegate ������RunDelegate ��������������������������������������� CoreText ��� Bug��������������� Feature������ + +��������� +============== +YYText ������ MIT ��������������������� LICENSE ��������� + + -- Gitblit v1.8.0