├── .gitignore ├── A_ClickableLabel ├── A_AttributedStringBuilder.h ├── A_AttributedStringBuilder.m ├── A_ClickableLabel.h └── A_ClickableLabel.m ├── A_ClickableLabel_Demo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── A_ClickableLabel_Demo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Demos │ ├── Demo1Controller.h │ ├── Demo1Controller.m │ ├── Demo2Controller.h │ ├── Demo2Controller.m │ ├── Demo3Controller.h │ ├── Demo3Controller.m │ ├── DemoDisplayView.h │ └── DemoDisplayView.m ├── Info.plist ├── RootTableController.h ├── RootTableController.m └── main.m ├── LICENSE ├── README.md └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /A_ClickableLabel/A_AttributedStringBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // A_AttributedStringBuilder.h 3 | // 4 | // Created by Animax Deng on 2/9/16. 5 | // Copyright © 2016 Animax Deng. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface A_AttributedStringBuilder : NSObject 12 | 13 | + (A_AttributedStringBuilder *)createWithSystemFontSize:(CGFloat)size; 14 | + (A_AttributedStringBuilder *)createWithFontName:(NSString *)name withSize:(CGFloat)size; 15 | + (A_AttributedStringBuilder *)createFromAttributes:(NSDictionary *)attributes; 16 | 17 | - (A_AttributedStringBuilder *)setAttributes:(NSDictionary *)attributes; 18 | - (A_AttributedStringBuilder *)setSystemFontSize:(CGFloat)size; 19 | - (A_AttributedStringBuilder *)setFontName:(NSString *)name withSize:(CGFloat)size; 20 | - (A_AttributedStringBuilder *)setKern:(CGFloat)kern; 21 | - (A_AttributedStringBuilder *)setParagraphStyle:(NSParagraphStyle *)style; 22 | - (A_AttributedStringBuilder *)setUnderline:(BOOL)underline; 23 | - (A_AttributedStringBuilder *)setShadow:(NSShadow *)shadow; 24 | - (A_AttributedStringBuilder *)setObliqueness:(CGFloat)obliqueness; 25 | - (A_AttributedStringBuilder *)setForegroundColor:(UIColor *)color; 26 | - (A_AttributedStringBuilder *)setBackgroundColor:(UIColor *)color; 27 | - (A_AttributedStringBuilder *)setStrokeColor:(UIColor *)color; 28 | - (A_AttributedStringBuilder *)setBaselineOffset:(CGFloat)offest; 29 | - (A_AttributedStringBuilder *)setUnderlineColor:(UIColor *)color; 30 | - (A_AttributedStringBuilder *)setExpansion:(CGFloat)offest; 31 | 32 | - (NSDictionary *)getStringAttributes; 33 | - (NSAttributedString *)getAttributedString:(NSString *)string; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /A_ClickableLabel/A_AttributedStringBuilder.m: -------------------------------------------------------------------------------- 1 | // 2 | // A_AttributedStringBuilder.m 3 | // 4 | // Created by Animax Deng on 2/9/16. 5 | // Copyright © 2016 Animax Deng. All rights reserved. 6 | // 7 | 8 | #import "A_AttributedStringBuilder.h" 9 | 10 | @implementation A_AttributedStringBuilder { 11 | NSMutableDictionary *attributed; 12 | } 13 | 14 | - (instancetype)init { 15 | self = [super init]; 16 | if (self) { 17 | attributed = [[NSMutableDictionary alloc] init]; 18 | } 19 | return self; 20 | } 21 | 22 | + (A_AttributedStringBuilder *)createWithSystemFontSize:(CGFloat)size { 23 | A_AttributedStringBuilder *builder = [A_AttributedStringBuilder new]; 24 | [builder setSystemFontSize:size]; 25 | return builder; 26 | } 27 | + (A_AttributedStringBuilder *)createWithFontName:(NSString *)name withSize:(CGFloat)size { 28 | A_AttributedStringBuilder *builder = [A_AttributedStringBuilder new]; 29 | [builder setFontName:name withSize:size]; 30 | return builder; 31 | } 32 | + (A_AttributedStringBuilder *)createFromAttributes:(NSDictionary *)attributes { 33 | A_AttributedStringBuilder *builder = [A_AttributedStringBuilder new]; 34 | [builder setAttributes:attributes]; 35 | return builder; 36 | } 37 | 38 | - (A_AttributedStringBuilder *)setAttributes:(NSDictionary *)attributes { 39 | [attributed setValuesForKeysWithDictionary:attributes]; 40 | return self; 41 | } 42 | - (A_AttributedStringBuilder *)setSystemFontSize:(CGFloat)size { 43 | UIFont *font = [UIFont systemFontOfSize:size]; 44 | [attributed setObject:font forKey:NSFontAttributeName]; 45 | return self; 46 | } 47 | - (A_AttributedStringBuilder *)setFontName:(NSString *)name withSize:(CGFloat)size { 48 | UIFont *font = [UIFont fontWithName:name size:size]; 49 | [attributed setObject:font forKey:NSFontAttributeName]; 50 | return self; 51 | } 52 | - (A_AttributedStringBuilder *)setKern:(CGFloat)kern { 53 | [attributed setObject:@(kern) forKey:NSKernAttributeName]; 54 | return self; 55 | } 56 | - (A_AttributedStringBuilder *)setParagraphStyle:(NSParagraphStyle *)style { 57 | [attributed setObject:style forKey:NSParagraphStyleAttributeName]; 58 | return self; 59 | } 60 | - (A_AttributedStringBuilder *)setUnderline:(BOOL)underline { 61 | [attributed setObject:@(underline) forKey:NSUnderlineStyleAttributeName]; 62 | return self; 63 | } 64 | - (A_AttributedStringBuilder *)setShadow:(NSShadow *)shadow{ 65 | [attributed setObject:shadow forKey:NSShadowAttributeName]; 66 | return self; 67 | } 68 | - (A_AttributedStringBuilder *)setObliqueness:(CGFloat)obliqueness { 69 | [attributed setObject:@(obliqueness) forKey:NSObliquenessAttributeName]; 70 | return self; 71 | } 72 | 73 | - (A_AttributedStringBuilder *)setForegroundColor:(UIColor *)color { 74 | [attributed setObject:color forKey:NSForegroundColorAttributeName]; 75 | return self; 76 | } 77 | - (A_AttributedStringBuilder *)setBackgroundColor:(UIColor *)color { 78 | [attributed setObject:color forKey:NSBackgroundColorAttributeName]; 79 | return self; 80 | } 81 | - (A_AttributedStringBuilder *)setStrokeColor:(UIColor *)color { 82 | [attributed setObject:color forKey:NSStrokeColorAttributeName]; 83 | return self; 84 | } 85 | - (A_AttributedStringBuilder *)setBaselineOffset:(CGFloat)offest { 86 | [attributed setObject:@(offest) forKey:NSBaselineOffsetAttributeName]; 87 | return self; 88 | } 89 | - (A_AttributedStringBuilder *)setUnderlineColor:(UIColor *)color { 90 | [attributed setObject:color forKey:NSUnderlineColorAttributeName]; 91 | return self; 92 | } 93 | - (A_AttributedStringBuilder *)setExpansion:(CGFloat)offest { 94 | [attributed setObject:@(offest) forKey:NSExpansionAttributeName]; 95 | return self; 96 | } 97 | 98 | 99 | - (NSDictionary *)getStringAttributes { 100 | return [attributed copy]; 101 | } 102 | - (NSAttributedString *)getAttributedString:(NSString *)string { 103 | NSAttributedString *str = [[NSAttributedString alloc] initWithString:string attributes:attributed]; 104 | return str; 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /A_ClickableLabel/A_ClickableLabel.h: -------------------------------------------------------------------------------- 1 | // 2 | // A_ClickableLabel.h 3 | // 4 | // Created by Animax Deng on 2/8/16. 5 | // Copyright © 2016 Animax Deng. All rights reserved. 6 | // 7 | 8 | #import 9 | #import "A_AttributedStringBuilder.h" 10 | 11 | @class A_ClickableElement; 12 | @class A_ClickableLabel; 13 | @class A_ClickedAdditionalInformation; 14 | 15 | typedef void(^aClickableLabelTouchEvent)(A_ClickableElement *element, A_ClickableLabel *sender, A_ClickedAdditionalInformation *info); 16 | 17 | @interface A_ClickableElement : NSObject 18 | 19 | @property (strong, nonatomic) A_AttributedStringBuilder *styleBuilder; 20 | @property (strong, nonatomic) NSString *elementWords; 21 | @property (copy, nonatomic) aClickableLabelTouchEvent touchEvent; 22 | 23 | + (A_ClickableElement *)create:(NSString *)words withAttributes:(NSDictionary *)attributes andClick:(aClickableLabelTouchEvent)touchEvent; 24 | + (A_ClickableElement *)create:(NSString *)words withBuilder:(A_AttributedStringBuilder *)builder andClick:(aClickableLabelTouchEvent)touchEvent; 25 | 26 | + (A_ClickableElement *)create:(NSString *)words withAttributes:(NSDictionary *)attributes; 27 | + (A_ClickableElement *)create:(NSString *)words withBuilder:(A_AttributedStringBuilder *)builder; 28 | 29 | 30 | @end 31 | 32 | @interface A_ClickedAdditionalInformation : NSObject 33 | 34 | @property (strong, nonatomic) NSString *selectedWord; 35 | @property (nonatomic) NSInteger locateNumberOfLine; 36 | @property (nonatomic) CGPoint clickedPoint; 37 | @property (nonatomic) CGPoint clickedBaselinePoint; 38 | @property (assign, nonatomic) CFIndex charIndexInSentence; 39 | 40 | @end 41 | 42 | @interface A_ClickableLabel : UILabel 43 | 44 | - (void)setSentence:(NSString *)sentence withAttributes:(NSDictionary *)stringAttributes andElements:(NSArray *)elements; 45 | - (void)setSentence:(NSString *)sentence withBuilder:(A_AttributedStringBuilder *)builder andElements:(NSArray *)elements; 46 | 47 | - (void)setSentence:(NSString *)sentence withAttributes:(NSDictionary *)stringAttributes andElement:(A_ClickableElement *)element, ...NS_REQUIRES_NIL_TERMINATION; 48 | - (void)setSentence:(NSString *)sentence withBuilder:(A_AttributedStringBuilder *)builder andElement:(A_ClickableElement *)element, ...NS_REQUIRES_NIL_TERMINATION; 49 | 50 | - (void)renderLabel; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /A_ClickableLabel/A_ClickableLabel.m: -------------------------------------------------------------------------------- 1 | // 2 | // A_ClickableLabel.m 3 | // 4 | // Created by Animax Deng on 2/8/16. 5 | // Copyright © 2016 Animax Deng. All rights reserved. 6 | // 7 | 8 | #import "A_ClickableLabel.h" 9 | #import 10 | 11 | @interface A_ClickableElement() 12 | 13 | @property (assign, nonatomic) NSRange changableRange; 14 | 15 | @end 16 | 17 | @implementation A_ClickableElement 18 | 19 | + (A_ClickableElement *)create:(NSString *)words withAttributes:(NSDictionary *)attributes andClick:(aClickableLabelTouchEvent)touchEvent { 20 | A_ClickableElement *element = [[A_ClickableElement alloc] init]; 21 | 22 | element.elementWords = words; 23 | element.styleBuilder = [A_AttributedStringBuilder createFromAttributes:attributes]; 24 | element.touchEvent = touchEvent; 25 | 26 | return element; 27 | } 28 | + (A_ClickableElement *)create:(NSString *)words withBuilder:(A_AttributedStringBuilder *)builder andClick:(aClickableLabelTouchEvent)touchEvent { 29 | A_ClickableElement *element = [[A_ClickableElement alloc] init]; 30 | 31 | element.elementWords = words; 32 | element.styleBuilder = builder; 33 | element.touchEvent = touchEvent; 34 | 35 | return element; 36 | 37 | } 38 | 39 | + (A_ClickableElement *)create:(NSString *)words withAttributes:(NSDictionary *)attributes { 40 | return [self create:words withAttributes:attributes andClick:nil]; 41 | } 42 | + (A_ClickableElement *)create:(NSString *)words withBuilder:(A_AttributedStringBuilder *)builder { 43 | return [self create:words withBuilder:builder andClick:nil]; 44 | } 45 | 46 | @end 47 | 48 | @implementation A_ClickedAdditionalInformation 49 | 50 | @end 51 | 52 | @implementation A_ClickableLabel { 53 | NSString *_contentSentence; 54 | NSDictionary *_attributes; 55 | NSArray *_elements; 56 | } 57 | 58 | - (void)setSentence:(NSString *)sentence withAttributes:(NSDictionary *)stringAttributes andElements:(NSArray *)elements { 59 | self.userInteractionEnabled = YES; 60 | 61 | _contentSentence = sentence; 62 | _elements = elements; 63 | _attributes = stringAttributes; 64 | 65 | [self renderLabel]; 66 | } 67 | - (void)setSentence:(NSString *)sentence withBuilder:(A_AttributedStringBuilder *)builder andElements:(NSArray *)elements { 68 | [self setSentence:sentence withAttributes:[builder getStringAttributes] andElements:elements]; 69 | } 70 | 71 | - (void)setSentence:(NSString *)sentence withAttributes:(NSDictionary *)stringAttributes andElement:(A_ClickableElement *)element, ...NS_REQUIRES_NIL_TERMINATION{ 72 | NSMutableArray *array = [[NSMutableArray alloc] init]; 73 | 74 | va_list args; 75 | va_start(args, element); 76 | for (A_ClickableElement *arg = element; arg != nil; arg = va_arg(args, A_ClickableElement *)) { 77 | [array addObject:arg]; 78 | } 79 | va_end(args); 80 | 81 | [self setSentence:sentence withAttributes:stringAttributes andElements:array]; 82 | } 83 | - (void)setSentence:(NSString *)sentence withBuilder:(A_AttributedStringBuilder *)builder andElement:(A_ClickableElement *)element, ...NS_REQUIRES_NIL_TERMINATION{ 84 | NSMutableArray *array = [[NSMutableArray alloc] init]; 85 | 86 | va_list args; 87 | va_start(args, element); 88 | for (A_ClickableElement *arg = element; arg != nil; arg = va_arg(args, A_ClickableElement *)) { 89 | [array addObject:arg]; 90 | } 91 | va_end(args); 92 | 93 | [self setSentence:sentence withBuilder:builder andElements:array]; 94 | } 95 | 96 | - (void)renderLabel { 97 | // calculate the range for each element words 98 | NSString *content = [_contentSentence copy]; 99 | for (int i = 0; i < _elements.count; i++) { 100 | NSRange range = [content rangeOfString:@"%@"]; 101 | content = [content stringByReplacingCharactersInRange:range withString:_elements[i].elementWords]; 102 | 103 | range.length = _elements[i].elementWords.length; 104 | _elements[i].changableRange = range; 105 | } 106 | 107 | NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:content]; 108 | [string addAttributes:_attributes range:NSMakeRange(0, content.length)]; 109 | for (A_ClickableElement *item in _elements) { 110 | [string addAttributes:[item.styleBuilder getStringAttributes] range:item.changableRange]; 111 | } 112 | 113 | [self setAttributedText:string]; 114 | } 115 | 116 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 117 | UITouch *touch = [touches anyObject]; 118 | CGPoint touchPoint = [touch locationInView:self]; 119 | A_ClickedAdditionalInformation *info = [self characterIndexAtPoint:touchPoint]; 120 | info.clickedPoint = touchPoint; 121 | if (info.charIndexInSentence == NSNotFound) return; 122 | 123 | for (A_ClickableElement *item in _elements) { 124 | if (item.changableRange.location <= info.charIndexInSentence && (item.changableRange.location + item.changableRange.length) >= info.charIndexInSentence && item.touchEvent) { 125 | 126 | item.touchEvent(item, self, info); 127 | [self renderLabel]; 128 | break; 129 | } 130 | } 131 | } 132 | 133 | #pragma mark - Helping methods 134 | - (A_ClickedAdditionalInformation *)characterIndexAtPoint:(CGPoint)p { 135 | // * This method is reference from TTTAttributedLabel 136 | // https://github.com/TTTAttributedLabel/TTTAttributedLabel/blob/master/TTTAttributedLabel/TTTAttributedLabel.m 137 | 138 | A_ClickedAdditionalInformation *info = [[A_ClickedAdditionalInformation alloc] init]; 139 | 140 | if (!CGRectContainsPoint(self.bounds, p)) { 141 | info.charIndexInSentence = NSNotFound; 142 | return info; 143 | } 144 | 145 | CGRect textRect = [self textRectForBounds:self.bounds limitedToNumberOfLines:self.numberOfLines]; 146 | textRect.origin.y = (self.bounds.size.height - textRect.size.height) / 2; 147 | 148 | if (self.textAlignment == NSTextAlignmentCenter) { 149 | textRect.origin.x = (self.bounds.size.width - textRect.size.width) / 2; 150 | } 151 | if (self.textAlignment == NSTextAlignmentRight) { 152 | textRect.origin.x = self.bounds.size.width - textRect.size.width; 153 | } 154 | 155 | if (!CGRectContainsPoint(textRect, p)) { 156 | info.charIndexInSentence = NSNotFound; 157 | return info; 158 | } 159 | 160 | // Offset tap coordinates by textRect origin to make them relative to the origin of frame 161 | p = CGPointMake(p.x - textRect.origin.x, textRect.size.height - (p.y - textRect.origin.y)); 162 | 163 | CGMutablePathRef path = CGPathCreateMutable(); 164 | CGPathAddRect(path, NULL, textRect); 165 | 166 | CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)self.attributedText); 167 | 168 | CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, (CFIndex)[self.attributedText length]), path, NULL); 169 | if (frame == NULL) { 170 | CFRelease(path); 171 | info.charIndexInSentence = NSNotFound; 172 | return info; 173 | } 174 | 175 | CFArrayRef lines = CTFrameGetLines(frame); 176 | NSInteger numberOfLines = self.numberOfLines > 0 ? MIN(self.numberOfLines, CFArrayGetCount(lines)) : CFArrayGetCount(lines); 177 | if (numberOfLines == 0) { 178 | CFRelease(frame); 179 | CFRelease(path); 180 | info.charIndexInSentence = NSNotFound; 181 | return info; 182 | } 183 | 184 | CFIndex idx = NSNotFound; 185 | 186 | CGPoint lineOrigins[numberOfLines]; 187 | CTFrameGetLineOrigins(frame, CFRangeMake(0, numberOfLines), lineOrigins); 188 | 189 | CGFloat totalLineHeight = 0.0f; 190 | 191 | for (CFIndex lineIndex = 0; lineIndex < numberOfLines; lineIndex++) { 192 | CGPoint lineOrigin = lineOrigins[lineIndex]; 193 | CTLineRef line = CFArrayGetValueAtIndex(lines, lineIndex); 194 | 195 | CGRect lineBounds = CTLineGetBoundsWithOptions(line, kCTLineBoundsUseOpticalBounds); 196 | totalLineHeight += lineBounds.size.height; 197 | 198 | // Get bounding information of line 199 | CGFloat ascent = 0.0f, descent = 0.0f, leading = 0.0f; 200 | CGFloat width = (CGFloat)CTLineGetTypographicBounds(line, &ascent, &descent, &leading); 201 | CGFloat yMin = (CGFloat)floor(lineOrigin.y - descent); 202 | CGFloat yMax = (CGFloat)ceil(lineOrigin.y + ascent); 203 | 204 | // Apply penOffset using flushFactor for horizontal alignment to set lineOrigin since this is the horizontal offset from drawFramesetter 205 | CGFloat flushFactor = 0.0f; 206 | if (self.textAlignment == NSTextAlignmentCenter) { 207 | flushFactor = 0.5f; 208 | } 209 | else if (self.textAlignment == NSTextAlignmentRight) { 210 | flushFactor = 1.0f; 211 | } 212 | 213 | CGFloat penOffset = (CGFloat)CTLineGetPenOffsetForFlush(line, flushFactor, textRect.size.width); 214 | lineOrigin.x = penOffset; 215 | 216 | // Check if we've already passed the line 217 | if (p.y > yMax) { 218 | break; 219 | } 220 | // Check if the point is within this line vertically 221 | if (p.y >= yMin) { 222 | // Check if the point is within this line horizontally 223 | if (p.x >= lineOrigin.x && p.x <= lineOrigin.x + width) { 224 | // Convert CT coordinates to line-relative coordinates 225 | CGPoint relativePoint = CGPointMake(p.x - lineOrigin.x, p.y - lineOrigin.y); 226 | idx = CTLineGetStringIndexForPosition(line, relativePoint); 227 | 228 | info.locateNumberOfLine = (NSInteger)lineIndex + 1; 229 | info.clickedBaselinePoint = CGPointMake(relativePoint.x + textRect.origin.x, totalLineHeight); 230 | 231 | break; 232 | } 233 | } 234 | } 235 | 236 | CFRelease(frame); 237 | CFRelease(path); 238 | 239 | NSRange range = [self getWordRange:idx]; 240 | info.selectedWord = [self.text substringWithRange:range]; 241 | info.charIndexInSentence = idx; 242 | return info; 243 | } 244 | - (NSRange)getWordRange:(CFIndex)index { 245 | NSString *string = [self.text copy]; 246 | 247 | NSCharacterSet *cset = [[NSCharacterSet alphanumericCharacterSet] invertedSet]; 248 | 249 | NSRange end = [string rangeOfCharacterFromSet:cset options:0 range:NSMakeRange(index, string.length - index)]; 250 | NSRange front = [string rangeOfCharacterFromSet:cset options:NSBackwardsSearch range:NSMakeRange(0, index)]; 251 | 252 | if (front.location == NSNotFound) { 253 | front.location = 0; 254 | } 255 | 256 | if (end.location == NSNotFound) { 257 | end.location = string.length; 258 | } 259 | 260 | return NSMakeRange(front.location, end.location-front.location); 261 | } 262 | 263 | 264 | @end 265 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 691E83A61C6929FB001A16F5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 691E83A51C6929FB001A16F5 /* main.m */; }; 11 | 691E83A91C6929FB001A16F5 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 691E83A81C6929FB001A16F5 /* AppDelegate.m */; }; 12 | 691E83AF1C6929FB001A16F5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 691E83AD1C6929FB001A16F5 /* Main.storyboard */; }; 13 | 691E83B11C6929FB001A16F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 691E83B01C6929FB001A16F5 /* Assets.xcassets */; }; 14 | 691E83B41C6929FB001A16F5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 691E83B21C6929FB001A16F5 /* LaunchScreen.storyboard */; }; 15 | 691E83CC1C69A8C6001A16F5 /* A_ClickableLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 691E83CB1C69A8C6001A16F5 /* A_ClickableLabel.m */; }; 16 | 691E83CF1C6A9339001A16F5 /* A_AttributedStringBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 691E83CE1C6A9339001A16F5 /* A_AttributedStringBuilder.m */; }; 17 | 691E83D21C6B98AF001A16F5 /* RootTableController.m in Sources */ = {isa = PBXBuildFile; fileRef = 691E83D11C6B98AF001A16F5 /* RootTableController.m */; }; 18 | 691E83DA1C6B99D3001A16F5 /* Demo1Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 691E83D91C6B99D3001A16F5 /* Demo1Controller.m */; }; 19 | 691E83E01C6D3DD3001A16F5 /* DemoDisplayView.m in Sources */ = {isa = PBXBuildFile; fileRef = 691E83DF1C6D3DD3001A16F5 /* DemoDisplayView.m */; }; 20 | 691E83FD1C6F93F2001A16F5 /* Demo2Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 691E83FC1C6F93F2001A16F5 /* Demo2Controller.m */; }; 21 | 691E840A1C740DC7001A16F5 /* Demo3Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 691E84091C740DC7001A16F5 /* Demo3Controller.m */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXFileReference section */ 25 | 691E83A11C6929FB001A16F5 /* A_ClickableLabel_Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = A_ClickableLabel_Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | 691E83A51C6929FB001A16F5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 27 | 691E83A71C6929FB001A16F5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 28 | 691E83A81C6929FB001A16F5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 29 | 691E83AE1C6929FB001A16F5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 30 | 691E83B01C6929FB001A16F5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 31 | 691E83B31C6929FB001A16F5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 32 | 691E83B51C6929FB001A16F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 691E83CA1C69A8C6001A16F5 /* A_ClickableLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = A_ClickableLabel.h; path = A_ClickableLabel/A_ClickableLabel.h; sourceTree = ""; }; 34 | 691E83CB1C69A8C6001A16F5 /* A_ClickableLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = A_ClickableLabel.m; path = A_ClickableLabel/A_ClickableLabel.m; sourceTree = ""; }; 35 | 691E83CD1C6A9339001A16F5 /* A_AttributedStringBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = A_AttributedStringBuilder.h; path = A_ClickableLabel/A_AttributedStringBuilder.h; sourceTree = ""; }; 36 | 691E83CE1C6A9339001A16F5 /* A_AttributedStringBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = A_AttributedStringBuilder.m; path = A_ClickableLabel/A_AttributedStringBuilder.m; sourceTree = ""; }; 37 | 691E83D01C6B98AF001A16F5 /* RootTableController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootTableController.h; sourceTree = ""; }; 38 | 691E83D11C6B98AF001A16F5 /* RootTableController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootTableController.m; sourceTree = ""; }; 39 | 691E83D81C6B99D3001A16F5 /* Demo1Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Demo1Controller.h; path = Demos/Demo1Controller.h; sourceTree = ""; }; 40 | 691E83D91C6B99D3001A16F5 /* Demo1Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Demo1Controller.m; path = Demos/Demo1Controller.m; sourceTree = ""; }; 41 | 691E83DE1C6D3DD3001A16F5 /* DemoDisplayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DemoDisplayView.h; path = Demos/DemoDisplayView.h; sourceTree = ""; }; 42 | 691E83DF1C6D3DD3001A16F5 /* DemoDisplayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DemoDisplayView.m; path = Demos/DemoDisplayView.m; sourceTree = ""; }; 43 | 691E83FB1C6F93F2001A16F5 /* Demo2Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Demo2Controller.h; path = Demos/Demo2Controller.h; sourceTree = ""; }; 44 | 691E83FC1C6F93F2001A16F5 /* Demo2Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Demo2Controller.m; path = Demos/Demo2Controller.m; sourceTree = ""; }; 45 | 691E84081C740DC7001A16F5 /* Demo3Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Demo3Controller.h; path = Demos/Demo3Controller.h; sourceTree = ""; }; 46 | 691E84091C740DC7001A16F5 /* Demo3Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Demo3Controller.m; path = Demos/Demo3Controller.m; sourceTree = ""; }; 47 | /* End PBXFileReference section */ 48 | 49 | /* Begin PBXFrameworksBuildPhase section */ 50 | 691E839E1C6929FB001A16F5 /* Frameworks */ = { 51 | isa = PBXFrameworksBuildPhase; 52 | buildActionMask = 2147483647; 53 | files = ( 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | 691E83981C6929FA001A16F5 = { 61 | isa = PBXGroup; 62 | children = ( 63 | 691E83C91C69A895001A16F5 /* A_ClickableLabel */, 64 | 691E83A31C6929FB001A16F5 /* A_ClickableLabel_Demo */, 65 | 691E83A21C6929FB001A16F5 /* Products */, 66 | ); 67 | sourceTree = ""; 68 | }; 69 | 691E83A21C6929FB001A16F5 /* Products */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 691E83A11C6929FB001A16F5 /* A_ClickableLabel_Demo.app */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | 691E83A31C6929FB001A16F5 /* A_ClickableLabel_Demo */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 691E83D41C6B9977001A16F5 /* NavigationPages */, 81 | 691E83D31C6B9958001A16F5 /* Demo1 */, 82 | 691E83F71C6F9354001A16F5 /* Demo2 */, 83 | 691E84071C7408B7001A16F5 /* Demo3 */, 84 | 691E83A41C6929FB001A16F5 /* Supporting Files */, 85 | ); 86 | path = A_ClickableLabel_Demo; 87 | sourceTree = ""; 88 | }; 89 | 691E83A41C6929FB001A16F5 /* Supporting Files */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 691E83A51C6929FB001A16F5 /* main.m */, 93 | ); 94 | name = "Supporting Files"; 95 | sourceTree = ""; 96 | }; 97 | 691E83C91C69A895001A16F5 /* A_ClickableLabel */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 691E83CA1C69A8C6001A16F5 /* A_ClickableLabel.h */, 101 | 691E83CB1C69A8C6001A16F5 /* A_ClickableLabel.m */, 102 | 691E83CD1C6A9339001A16F5 /* A_AttributedStringBuilder.h */, 103 | 691E83CE1C6A9339001A16F5 /* A_AttributedStringBuilder.m */, 104 | ); 105 | name = A_ClickableLabel; 106 | sourceTree = ""; 107 | }; 108 | 691E83D31C6B9958001A16F5 /* Demo1 */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 691E83DE1C6D3DD3001A16F5 /* DemoDisplayView.h */, 112 | 691E83DF1C6D3DD3001A16F5 /* DemoDisplayView.m */, 113 | 691E83D81C6B99D3001A16F5 /* Demo1Controller.h */, 114 | 691E83D91C6B99D3001A16F5 /* Demo1Controller.m */, 115 | ); 116 | name = Demo1; 117 | sourceTree = ""; 118 | }; 119 | 691E83D41C6B9977001A16F5 /* NavigationPages */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 691E83A71C6929FB001A16F5 /* AppDelegate.h */, 123 | 691E83A81C6929FB001A16F5 /* AppDelegate.m */, 124 | 691E83D01C6B98AF001A16F5 /* RootTableController.h */, 125 | 691E83D11C6B98AF001A16F5 /* RootTableController.m */, 126 | 691E83B01C6929FB001A16F5 /* Assets.xcassets */, 127 | 691E83AD1C6929FB001A16F5 /* Main.storyboard */, 128 | 691E83B21C6929FB001A16F5 /* LaunchScreen.storyboard */, 129 | 691E83B51C6929FB001A16F5 /* Info.plist */, 130 | ); 131 | name = NavigationPages; 132 | sourceTree = ""; 133 | }; 134 | 691E83F71C6F9354001A16F5 /* Demo2 */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 691E83FB1C6F93F2001A16F5 /* Demo2Controller.h */, 138 | 691E83FC1C6F93F2001A16F5 /* Demo2Controller.m */, 139 | ); 140 | name = Demo2; 141 | sourceTree = ""; 142 | }; 143 | 691E84071C7408B7001A16F5 /* Demo3 */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 691E84081C740DC7001A16F5 /* Demo3Controller.h */, 147 | 691E84091C740DC7001A16F5 /* Demo3Controller.m */, 148 | ); 149 | name = Demo3; 150 | sourceTree = ""; 151 | }; 152 | /* End PBXGroup section */ 153 | 154 | /* Begin PBXNativeTarget section */ 155 | 691E83A01C6929FB001A16F5 /* A_ClickableLabel_Demo */ = { 156 | isa = PBXNativeTarget; 157 | buildConfigurationList = 691E83C31C6929FB001A16F5 /* Build configuration list for PBXNativeTarget "A_ClickableLabel_Demo" */; 158 | buildPhases = ( 159 | 691E839D1C6929FB001A16F5 /* Sources */, 160 | 691E839E1C6929FB001A16F5 /* Frameworks */, 161 | 691E839F1C6929FB001A16F5 /* Resources */, 162 | ); 163 | buildRules = ( 164 | ); 165 | dependencies = ( 166 | ); 167 | name = A_ClickableLabel_Demo; 168 | productName = A_ClickableLabel_Demo; 169 | productReference = 691E83A11C6929FB001A16F5 /* A_ClickableLabel_Demo.app */; 170 | productType = "com.apple.product-type.application"; 171 | }; 172 | /* End PBXNativeTarget section */ 173 | 174 | /* Begin PBXProject section */ 175 | 691E83991C6929FA001A16F5 /* Project object */ = { 176 | isa = PBXProject; 177 | attributes = { 178 | LastUpgradeCheck = 0720; 179 | ORGANIZATIONNAME = "Animax Deng"; 180 | TargetAttributes = { 181 | 691E83A01C6929FB001A16F5 = { 182 | CreatedOnToolsVersion = 7.2; 183 | DevelopmentTeam = M979YDKC23; 184 | }; 185 | }; 186 | }; 187 | buildConfigurationList = 691E839C1C6929FA001A16F5 /* Build configuration list for PBXProject "A_ClickableLabel_Demo" */; 188 | compatibilityVersion = "Xcode 3.2"; 189 | developmentRegion = English; 190 | hasScannedForEncodings = 0; 191 | knownRegions = ( 192 | en, 193 | Base, 194 | ); 195 | mainGroup = 691E83981C6929FA001A16F5; 196 | productRefGroup = 691E83A21C6929FB001A16F5 /* Products */; 197 | projectDirPath = ""; 198 | projectRoot = ""; 199 | targets = ( 200 | 691E83A01C6929FB001A16F5 /* A_ClickableLabel_Demo */, 201 | ); 202 | }; 203 | /* End PBXProject section */ 204 | 205 | /* Begin PBXResourcesBuildPhase section */ 206 | 691E839F1C6929FB001A16F5 /* Resources */ = { 207 | isa = PBXResourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | 691E83B41C6929FB001A16F5 /* LaunchScreen.storyboard in Resources */, 211 | 691E83B11C6929FB001A16F5 /* Assets.xcassets in Resources */, 212 | 691E83AF1C6929FB001A16F5 /* Main.storyboard in Resources */, 213 | ); 214 | runOnlyForDeploymentPostprocessing = 0; 215 | }; 216 | /* End PBXResourcesBuildPhase section */ 217 | 218 | /* Begin PBXSourcesBuildPhase section */ 219 | 691E839D1C6929FB001A16F5 /* Sources */ = { 220 | isa = PBXSourcesBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | 691E840A1C740DC7001A16F5 /* Demo3Controller.m in Sources */, 224 | 691E83CF1C6A9339001A16F5 /* A_AttributedStringBuilder.m in Sources */, 225 | 691E83D21C6B98AF001A16F5 /* RootTableController.m in Sources */, 226 | 691E83E01C6D3DD3001A16F5 /* DemoDisplayView.m in Sources */, 227 | 691E83DA1C6B99D3001A16F5 /* Demo1Controller.m in Sources */, 228 | 691E83A91C6929FB001A16F5 /* AppDelegate.m in Sources */, 229 | 691E83A61C6929FB001A16F5 /* main.m in Sources */, 230 | 691E83CC1C69A8C6001A16F5 /* A_ClickableLabel.m in Sources */, 231 | 691E83FD1C6F93F2001A16F5 /* Demo2Controller.m in Sources */, 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | /* End PBXSourcesBuildPhase section */ 236 | 237 | /* Begin PBXVariantGroup section */ 238 | 691E83AD1C6929FB001A16F5 /* Main.storyboard */ = { 239 | isa = PBXVariantGroup; 240 | children = ( 241 | 691E83AE1C6929FB001A16F5 /* Base */, 242 | ); 243 | name = Main.storyboard; 244 | sourceTree = ""; 245 | }; 246 | 691E83B21C6929FB001A16F5 /* LaunchScreen.storyboard */ = { 247 | isa = PBXVariantGroup; 248 | children = ( 249 | 691E83B31C6929FB001A16F5 /* Base */, 250 | ); 251 | name = LaunchScreen.storyboard; 252 | sourceTree = ""; 253 | }; 254 | /* End PBXVariantGroup section */ 255 | 256 | /* Begin XCBuildConfiguration section */ 257 | 691E83C11C6929FB001A16F5 /* Debug */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 262 | CLANG_CXX_LIBRARY = "libc++"; 263 | CLANG_ENABLE_MODULES = YES; 264 | CLANG_ENABLE_OBJC_ARC = YES; 265 | CLANG_WARN_BOOL_CONVERSION = YES; 266 | CLANG_WARN_CONSTANT_CONVERSION = YES; 267 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 268 | CLANG_WARN_EMPTY_BODY = YES; 269 | CLANG_WARN_ENUM_CONVERSION = YES; 270 | CLANG_WARN_INT_CONVERSION = YES; 271 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 272 | CLANG_WARN_UNREACHABLE_CODE = YES; 273 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 274 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 275 | COPY_PHASE_STRIP = NO; 276 | DEBUG_INFORMATION_FORMAT = dwarf; 277 | ENABLE_STRICT_OBJC_MSGSEND = YES; 278 | ENABLE_TESTABILITY = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu99; 280 | GCC_DYNAMIC_NO_PIC = NO; 281 | GCC_NO_COMMON_BLOCKS = YES; 282 | GCC_OPTIMIZATION_LEVEL = 0; 283 | GCC_PREPROCESSOR_DEFINITIONS = ( 284 | "DEBUG=1", 285 | "$(inherited)", 286 | ); 287 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 288 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 289 | GCC_WARN_UNDECLARED_SELECTOR = YES; 290 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 291 | GCC_WARN_UNUSED_FUNCTION = YES; 292 | GCC_WARN_UNUSED_VARIABLE = YES; 293 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 294 | MTL_ENABLE_DEBUG_INFO = YES; 295 | ONLY_ACTIVE_ARCH = YES; 296 | SDKROOT = iphoneos; 297 | }; 298 | name = Debug; 299 | }; 300 | 691E83C21C6929FB001A16F5 /* Release */ = { 301 | isa = XCBuildConfiguration; 302 | buildSettings = { 303 | ALWAYS_SEARCH_USER_PATHS = NO; 304 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 305 | CLANG_CXX_LIBRARY = "libc++"; 306 | CLANG_ENABLE_MODULES = YES; 307 | CLANG_ENABLE_OBJC_ARC = YES; 308 | CLANG_WARN_BOOL_CONVERSION = YES; 309 | CLANG_WARN_CONSTANT_CONVERSION = YES; 310 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 311 | CLANG_WARN_EMPTY_BODY = YES; 312 | CLANG_WARN_ENUM_CONVERSION = YES; 313 | CLANG_WARN_INT_CONVERSION = YES; 314 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 315 | CLANG_WARN_UNREACHABLE_CODE = YES; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 318 | COPY_PHASE_STRIP = NO; 319 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 320 | ENABLE_NS_ASSERTIONS = NO; 321 | ENABLE_STRICT_OBJC_MSGSEND = YES; 322 | GCC_C_LANGUAGE_STANDARD = gnu99; 323 | GCC_NO_COMMON_BLOCKS = YES; 324 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 325 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 326 | GCC_WARN_UNDECLARED_SELECTOR = YES; 327 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 328 | GCC_WARN_UNUSED_FUNCTION = YES; 329 | GCC_WARN_UNUSED_VARIABLE = YES; 330 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 331 | MTL_ENABLE_DEBUG_INFO = NO; 332 | SDKROOT = iphoneos; 333 | VALIDATE_PRODUCT = YES; 334 | }; 335 | name = Release; 336 | }; 337 | 691E83C41C6929FB001A16F5 /* Debug */ = { 338 | isa = XCBuildConfiguration; 339 | buildSettings = { 340 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 341 | INFOPLIST_FILE = A_ClickableLabel_Demo/Info.plist; 342 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 343 | PRODUCT_BUNDLE_IDENTIFIER = "animax.A-ClickableLabel-Demo"; 344 | PRODUCT_NAME = "$(TARGET_NAME)"; 345 | }; 346 | name = Debug; 347 | }; 348 | 691E83C51C6929FB001A16F5 /* Release */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 352 | INFOPLIST_FILE = A_ClickableLabel_Demo/Info.plist; 353 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 354 | PRODUCT_BUNDLE_IDENTIFIER = "animax.A-ClickableLabel-Demo"; 355 | PRODUCT_NAME = "$(TARGET_NAME)"; 356 | }; 357 | name = Release; 358 | }; 359 | /* End XCBuildConfiguration section */ 360 | 361 | /* Begin XCConfigurationList section */ 362 | 691E839C1C6929FA001A16F5 /* Build configuration list for PBXProject "A_ClickableLabel_Demo" */ = { 363 | isa = XCConfigurationList; 364 | buildConfigurations = ( 365 | 691E83C11C6929FB001A16F5 /* Debug */, 366 | 691E83C21C6929FB001A16F5 /* Release */, 367 | ); 368 | defaultConfigurationIsVisible = 0; 369 | defaultConfigurationName = Release; 370 | }; 371 | 691E83C31C6929FB001A16F5 /* Build configuration list for PBXNativeTarget "A_ClickableLabel_Demo" */ = { 372 | isa = XCConfigurationList; 373 | buildConfigurations = ( 374 | 691E83C41C6929FB001A16F5 /* Debug */, 375 | 691E83C51C6929FB001A16F5 /* Release */, 376 | ); 377 | defaultConfigurationIsVisible = 0; 378 | defaultConfigurationName = Release; 379 | }; 380 | /* End XCConfigurationList section */ 381 | }; 382 | rootObject = 691E83991C6929FA001A16F5 /* Project object */; 383 | } 384 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/8/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/8/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 120 | 127 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 176 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 218 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Demos/Demo1Controller.h: -------------------------------------------------------------------------------- 1 | // 2 | // Demo1Controller.h 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/10/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Demo1Controller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Demos/Demo1Controller.m: -------------------------------------------------------------------------------- 1 | // 2 | // Demo1Controller.m 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/10/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "Demo1Controller.h" 10 | #import "A_AttributedStringBuilder.h" 11 | #import "A_ClickableLabel.h" 12 | #import "DemoDisplayView.h" 13 | 14 | @interface Demo1Controller () 15 | 16 | @property (weak, nonatomic) IBOutlet A_ClickableLabel *demoLabel; 17 | @property (weak, nonatomic) IBOutlet DemoDisplayView *demoView; 18 | 19 | @end 20 | 21 | @implementation Demo1Controller 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | A_ClickableElement *element = [A_ClickableElement create:@"a natural phenomenon" withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:14] setUnderline:YES] andClick:^(A_ClickableElement *element, A_ClickableLabel *sender, A_ClickedAdditionalInformation *info) { 27 | 28 | element.elementWords = @"a mathematical"; 29 | 30 | }]; 31 | 32 | [self.demoLabel setSentence:@"A fractal is %@ set that exhibits a repeating pattern that displays at every scale." withBuilder:[A_AttributedStringBuilder createWithSystemFontSize:16] andElements: @[element]]; 33 | } 34 | 35 | - (IBAction)onClick:(id)sender { 36 | [self.demoView draw:self.demoLabel.attributedText]; 37 | [self.demoView setHidden:NO]; 38 | } 39 | 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Demos/Demo2Controller.h: -------------------------------------------------------------------------------- 1 | // 2 | // Demo2Controller.h 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/13/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Demo2Controller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Demos/Demo2Controller.m: -------------------------------------------------------------------------------- 1 | // 2 | // Demo2Controller.m 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/13/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "Demo2Controller.h" 10 | #import "A_ClickableLabel.h" 11 | #import "A_AttributedStringBuilder.h" 12 | 13 | @interface Demo2Controller () 14 | 15 | @property (weak, nonatomic) IBOutlet A_ClickableLabel *demoLabel; 16 | @property (strong, nonatomic) UIView *explainArea; 17 | 18 | @end 19 | 20 | @implementation Demo2Controller { 21 | UILabel *noteLabel; 22 | } 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | 27 | _explainArea = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; 28 | _explainArea.backgroundColor = [UIColor blackColor]; 29 | _explainArea.layer.cornerRadius = 5.0f; 30 | 31 | [self.view addSubview:_explainArea]; 32 | 33 | noteLabel = [[UILabel alloc] init]; 34 | noteLabel.font = [UIFont systemFontOfSize:12]; 35 | noteLabel.textColor = [UIColor whiteColor]; 36 | [_explainArea addSubview:noteLabel]; 37 | 38 | noteLabel.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight); 39 | 40 | aClickableLabelTouchEvent touchEvent = ^(A_ClickableElement *element, A_ClickableLabel *sender, A_ClickedAdditionalInformation *info) { 41 | 42 | self.explainArea.frame = CGRectMake(sender.frame.origin.x + info.clickedBaselinePoint.x - 30.0f, sender.frame.origin.y + info.clickedBaselinePoint.y, 140, 30); 43 | [noteLabel setText:[NSString stringWithFormat:@" Note:%@", info.selectedWord]]; 44 | 45 | }; 46 | 47 | A_ClickableElement *phenomenon = [A_ClickableElement create:@"phenomenon" withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:14] setUnderline:YES] andClick:touchEvent]; 48 | 49 | A_ClickableElement *mathematical = [A_ClickableElement create:@"mathematical" withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:18] setUnderline:YES] andClick:touchEvent]; 50 | 51 | A_ClickableElement *exhibits = [A_ClickableElement create:@"exhibits" withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:12] setUnderline:YES] andClick:touchEvent]; 52 | 53 | A_ClickableElement *scale = [A_ClickableElement create:@"scale" withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:13] setUnderline:YES] andClick:touchEvent]; 54 | 55 | [self.demoLabel setSentence:@"A fractal is a natural %@ or a %@ set that %@ a repeating pattern that displays at every %@." withBuilder:[A_AttributedStringBuilder createWithSystemFontSize:16] andElements: @[phenomenon, mathematical, exhibits, scale]]; 56 | 57 | } 58 | 59 | - (IBAction)onClickBackgound:(id)sender { 60 | self.explainArea.frame = CGRectMake(0,0,0,0); 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Demos/Demo3Controller.h: -------------------------------------------------------------------------------- 1 | // 2 | // Demo3Controller.h 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/16/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Demo3Controller : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Demos/Demo3Controller.m: -------------------------------------------------------------------------------- 1 | // 2 | // Demo3Controller.m 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/16/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "Demo3Controller.h" 10 | #import "A_ClickableLabel.h" 11 | 12 | @interface Demo3Controller () 13 | 14 | @property (weak, nonatomic) IBOutlet A_ClickableLabel *demoLabel; 15 | @property (strong, nonatomic) UIView *explainArea; 16 | 17 | @end 18 | 19 | @implementation Demo3Controller { 20 | A_ClickableLabel *switchLabel; 21 | A_ClickableElement *world; 22 | } 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | 27 | // the clickable and changable element 28 | world = [A_ClickableElement create:@"World" withBuilder:[[[[A_AttributedStringBuilder createWithFontName:@"Helvetica-Bold" withSize:20] setForegroundColor:[UIColor blackColor]] setUnderline:YES] setUnderlineColor:[UIColor greenColor]] andClick:^(A_ClickableElement *element, A_ClickableLabel *sender, A_ClickedAdditionalInformation *info) { 29 | 30 | self.explainArea.frame = CGRectMake(sender.frame.origin.x + info.clickedPoint.x - 40.0f, sender.frame.origin.y + info.clickedPoint.y, 110, 30); 31 | 32 | }]; 33 | 34 | // Draw popup 35 | _explainArea = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; 36 | _explainArea.backgroundColor = [UIColor blackColor]; 37 | _explainArea.layer.cornerRadius = 5.0f; 38 | 39 | [self.view addSubview:_explainArea]; 40 | 41 | switchLabel = [[A_ClickableLabel alloc] init]; 42 | [switchLabel setSentence:@" %@|%@ " withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:14] setForegroundColor:[UIColor whiteColor]] andElement: 43 | [A_ClickableElement create:@"World" withBuilder:[A_AttributedStringBuilder createWithSystemFontSize:16] andClick:^(A_ClickableElement *element, A_ClickableLabel *sender, A_ClickedAdditionalInformation *info) { 44 | 45 | world.elementWords = @"World"; 46 | [self.demoLabel renderLabel]; 47 | _explainArea.frame = CGRectMake(0, 0, 0, 0); 48 | 49 | }], [A_ClickableElement create:@"Animax" withBuilder:[A_AttributedStringBuilder createWithSystemFontSize:16] andClick:^(A_ClickableElement *element, A_ClickableLabel *sender, A_ClickedAdditionalInformation *info) { 50 | 51 | world.elementWords = @"Animax"; 52 | [self.demoLabel renderLabel]; 53 | _explainArea.frame = CGRectMake(0, 0, 0, 0); 54 | 55 | }], nil]; 56 | [_explainArea addSubview:switchLabel]; 57 | 58 | switchLabel.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight); 59 | 60 | 61 | 62 | 63 | // Draw the sentence 64 | NSShadow *shadow = [[NSShadow alloc] init]; 65 | shadow.shadowBlurRadius = 0.6f; 66 | shadow.shadowColor = [UIColor orangeColor]; 67 | 68 | [self.demoLabel setSentence:@"%@%@%@%@%@ %@\n" withBuilder:[A_AttributedStringBuilder createWithSystemFontSize:16] andElement: 69 | [A_ClickableElement create:@"H" withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:18] setForegroundColor:[UIColor redColor]]], 70 | [A_ClickableElement create:@"e" withBuilder:[[[A_AttributedStringBuilder createWithFontName:@"Helvetica-Bold" withSize:10] setForegroundColor:[UIColor blackColor]] setBaselineOffset:6]], 71 | [A_ClickableElement create:@"l" withBuilder:[[[A_AttributedStringBuilder createWithSystemFontSize:14] setForegroundColor:[UIColor blueColor]] setObliqueness:0.1f]], 72 | [A_ClickableElement create:@"l" withBuilder:[[[A_AttributedStringBuilder createWithSystemFontSize:16] setForegroundColor:[UIColor greenColor]] setShadow:shadow]], 73 | [A_ClickableElement create:@"o" withBuilder:[[[[A_AttributedStringBuilder createWithSystemFontSize:16] setForegroundColor:[UIColor redColor]] setExpansion:0.8f] setShadow:shadow]], 74 | world, nil 75 | ]; 76 | } 77 | 78 | 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Demos/DemoDisplayView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DemoDisplayView.h 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/11/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DemoDisplayView : UIView 12 | 13 | - (void)draw: (NSAttributedString*)attributedText; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Demos/DemoDisplayView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DemoDisplayView.m 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/11/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "DemoDisplayView.h" 10 | #import 11 | 12 | @implementation DemoDisplayView { 13 | NSAttributedString *_attributedText; 14 | } 15 | 16 | - (void)draw: (NSAttributedString*)attributedText { 17 | _attributedText = attributedText; 18 | [self setNeedsDisplay]; 19 | } 20 | 21 | - (void)drawRect:(CGRect)rect { 22 | [super drawRect:rect]; 23 | 24 | if (!_attributedText) { 25 | return; 26 | } 27 | 28 | CGContextRef context = UIGraphicsGetCurrentContext(); 29 | 30 | CGContextSetTextMatrix(context, CGAffineTransformIdentity); 31 | CGContextTranslateCTM(context, 0, self.bounds.size.height); 32 | CGContextScaleCTM(context, 1.0, -1.0); 33 | 34 | CGMutablePathRef path = CGPathCreateMutable(); 35 | CGPathAddEllipseInRect(path, NULL, self.bounds); 36 | 37 | CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)_attributedText); 38 | 39 | CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, (CFIndex)[_attributedText length]), path, NULL); 40 | if (frame == NULL) { 41 | CFRelease(path); 42 | return; 43 | } 44 | 45 | CTFrameDraw(frame, context); 46 | 47 | CFRelease(frame); 48 | CFRelease(path); 49 | CFRelease(framesetter); 50 | } 51 | @end 52 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/RootTableController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RootTableController.h 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/10/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RootTableController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/RootTableController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RootTableController.m 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/10/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "RootTableController.h" 10 | 11 | @interface RootTableController () 12 | 13 | @end 14 | 15 | @implementation RootTableController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | // Uncomment the following line to preserve selection between presentations. 21 | // self.clearsSelectionOnViewWillAppear = NO; 22 | 23 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 24 | // self.navigationItem.rightBarButtonItem = self.editButtonItem; 25 | } 26 | 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /A_ClickableLabel_Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // A_ClickableLabel_Demo 4 | // 5 | // Created by Animax Deng on 2/8/16. 6 | // Copyright © 2016 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Animax Deng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A-ClickableLabel 2 | A clickable and replaceable label, you can define touch event for each character. 3 | 4 | ### Demo 5 | ![demo gif](https://raw.githubusercontent.com/Animaxx/A-ClickableLabel/master/demo.gif) 6 | 7 | ### Classes 8 | **A_AttributedStringBuilder** is for generating custom style for your label; it can apply to either the whole sentence or a clickable element. 9 | 10 | **A_ClickableElement** representing a clickable and replaceable element in the label. 11 | 12 | **A_ClickedAdditionalInformation** included all infomration about the click event: clicked point, baseline point, clicked at which character, clicked at which line ,and current word. 13 | 14 | **A_ClickableLabel** derived from UILabel for handle clickable and replaceable events. 15 | 16 | ### Usage 17 | ```objective-c 18 | [self.demoLabel setSentence:@"Hello %@." // set the sentence as "Hello world" 19 | 20 | // set style for whole sentence 21 | withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:14] setUnderline:YES] 22 | 23 | // the "world" is the clickable element in this label 24 | andElement:[A_ClickableElement create:@"world" 25 | 26 | // set the style for this element 27 | withBuilder:[[A_AttributedStringBuilder createWithSystemFontSize:18] setUnderlineColor:[UIColor redColor]] 28 | andClick:^(A_ClickableElement *element, A_ClickableLabel *sender, A_ClickedAdditionalInformation *info) { 29 | 30 | // when user click on the element, update the style 31 | [element.styleBuilder setUnderlineColor:[UIColor greenColor]]; 32 | 33 | }], nil 34 | ]; 35 | ``` -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Animaxx/A-ClickableLabel/83dd77515eba64aeac321ce65a6d8f3b62e36b8f/demo.gif --------------------------------------------------------------------------------