├── .gitignore ├── ARCGPathFromString.podspec ├── ARCGPathFromString ├── ARCGPathFromString.h ├── ARCGPathFromString.m ├── UIBezierPath+TextPaths.h └── UIBezierPath+TextPaths.m ├── CHANGES.md ├── LICENSE ├── README.md ├── Text2CGPathDemo.xcodeproj └── project.pbxproj └── Text2CGPathDemo ├── ARAppDelegate.h ├── ARAppDelegate.m ├── ARViewController.h ├── ARViewController.m ├── Base.lproj └── MainStoryboard.storyboard ├── Default-568h@2x.png ├── Default.png ├── Default@2x.png ├── SwiftViewController.swift ├── Text2CGPathDemo-Bridging-Header.h ├── Text2CGPathDemo-Info.plist ├── Text2CGPathDemo-Prefix.pch ├── en.lproj └── InfoPlist.strings └── main.m /.gitignore: -------------------------------------------------------------------------------- 1 | *.xcuserstate 2 | project.xcworkspace/ 3 | xcuserdata/ 4 | .DS_Store -------------------------------------------------------------------------------- /ARCGPathFromString.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint ARCGPathFromString.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = "ARCGPathFromString" 11 | s.version = "1.1.0" 12 | s.summary = "Takes in an NSString or NSAttributedString and creates a CGPathRef for that string." 13 | s.description = "This CocoaPod provides methods for creating CGPaths from NSStrings and NSAttributedStrings. A category for UIBezierPath also allows UIBezierPaths to be produced from strings." 14 | 15 | s.homepage = "https://github.com/aderussell/string-to-CGPathRef" 16 | 17 | # s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2" 18 | 19 | s.license = 'MIT' 20 | s.author = { "aderussell" => "adrianrussell@me.com" } 21 | s.social_media_url = 'https://twitter.com/ade177' 22 | 23 | s.source = { :git => "https://github.com/aderussell/string-to-CGPathRef.git", :tag => s.version.to_s } 24 | 25 | 26 | s.platform = :ios, '6.0' 27 | s.requires_arc = true 28 | 29 | s.source_files = 'ARCGPathFromString/*' 30 | 31 | 32 | s.frameworks = 'Foundation', 'CoreText' 33 | end 34 | -------------------------------------------------------------------------------- /ARCGPathFromString/ARCGPathFromString.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARCGPathFromString.h 3 | // 4 | // Created by Adrian Russell on 08/08/2014. 5 | // Copyright (c) 2014 Adrian Russell. All rights reserved. 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. Permission is granted to anyone to 10 | // use this software for any purpose, including commercial applications, and to 11 | // alter it and redistribute it freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would be 16 | // appreciated but is not required. 17 | // 2. Altered source versions must be plainly marked as such, and must not be 18 | // misrepresented as being the original software. 19 | // 3. This notice may not be removed or altered from any source 20 | // distribution. 21 | // 22 | 23 | #import 24 | #import 25 | 26 | NS_ASSUME_NONNULL_BEGIN 27 | 28 | /** 29 | Creates a CGPath from a specified attributed string. 30 | @param attrString The attributed string to produce the path for. Must not be `nil`. 31 | @return A new CGPath that contains a path with paths for all the glyphs for specifed string. 32 | @discussion This string will always be on a single line even if the string contains linebreaks. 33 | */ 34 | CGPathRef CGPathCreateSingleLineStringWithAttributedString(NSAttributedString *attrString) CF_RETURNS_RETAINED; 35 | 36 | /** 37 | Creates a CGPath from a specified attributed string that can span over multiple lines of text. 38 | @param attrString The attributed string to produce the path for. Must not be `nil`. 39 | @param maxWidth The maximum width of a line, if a line when rendered is longer than this width then the line is broken to a new line. Must be greater than 0. 40 | @param maxHeight The maximum height of the text block. Must be greater than 0. 41 | @return A new CGPath that contains a path with paths for all the glyphs for specifed string. 42 | */ 43 | CGPathRef CGPathCreateMultilineStringWithAttributedString(NSAttributedString *attrString, CGFloat maxWidth, CGFloat maxHeight) CF_RETURNS_RETAINED; 44 | 45 | NS_ASSUME_NONNULL_END 46 | -------------------------------------------------------------------------------- /ARCGPathFromString/ARCGPathFromString.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARCGPathFromString.m 3 | // 4 | // Created by Adrian Russell on 08/08/2014. 5 | // Copyright (c) 2014 Adrian Russell. All rights reserved. 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. Permission is granted to anyone to 10 | // use this software for any purpose, including commercial applications, and to 11 | // alter it and redistribute it freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would be 16 | // appreciated but is not required. 17 | // 2. Altered source versions must be plainly marked as such, and must not be 18 | // misrepresented as being the original software. 19 | // 3. This notice may not be removed or altered from any source 20 | // distribution. 21 | // 22 | 23 | #import "ARCGPathFromString.h" 24 | 25 | #pragma mark Single Line String Path 26 | 27 | CGPathRef CGPathCreateSingleLineStringWithAttributedString(NSAttributedString *attrString) 28 | { 29 | CGMutablePathRef letters = CGPathCreateMutable(); 30 | 31 | 32 | CTLineRef line = CTLineCreateWithAttributedString((__bridge CFAttributedStringRef)attrString); 33 | 34 | CFArrayRef runArray = CTLineGetGlyphRuns(line); 35 | 36 | // for each RUN 37 | for (CFIndex runIndex = 0; runIndex < CFArrayGetCount(runArray); runIndex++) 38 | { 39 | // Get FONT for this run 40 | CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runArray, runIndex); 41 | CTFontRef runFont = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName); 42 | 43 | // for each GLYPH in run 44 | for (CFIndex runGlyphIndex = 0; runGlyphIndex < CTRunGetGlyphCount(run); runGlyphIndex++) 45 | { 46 | // get Glyph & Glyph-data 47 | CFRange thisGlyphRange = CFRangeMake(runGlyphIndex, 1); 48 | CGGlyph glyph; 49 | CGPoint position; 50 | CTRunGetGlyphs(run, thisGlyphRange, &glyph); 51 | CTRunGetPositions(run, thisGlyphRange, &position); 52 | 53 | // Get PATH of outline 54 | { 55 | CGPathRef letter = CTFontCreatePathForGlyph(runFont, glyph, NULL); 56 | CGAffineTransform t = CGAffineTransformMakeTranslation(position.x, position.y); 57 | CGPathAddPath(letters, &t, letter); 58 | CGPathRelease(letter); 59 | } 60 | } 61 | } 62 | 63 | CFRelease(line); 64 | 65 | CGPathRef finalPath = CGPathCreateCopy(letters); 66 | CGPathRelease(letters); 67 | return finalPath; 68 | } 69 | 70 | 71 | #pragma mark - Multiple Line String Path 72 | 73 | CGPathRef CGPathCreateMultilineStringWithAttributedString(NSAttributedString *attrString, CGFloat maxWidth, CGFloat maxHeight) 74 | { 75 | 76 | CGMutablePathRef letters = CGPathCreateMutable(); 77 | 78 | CGRect bounds = CGRectMake(0, 0, maxWidth, maxHeight); 79 | 80 | CGPathRef pathRef = CGPathCreateWithRect(bounds, NULL); 81 | 82 | CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)(attrString)); 83 | CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), pathRef, NULL); 84 | 85 | CFArrayRef lines = CTFrameGetLines(frame); 86 | 87 | CGPoint *points = malloc(sizeof(CGPoint) * CFArrayGetCount(lines)); 88 | 89 | CTFrameGetLineOrigins(frame, CFRangeMake(0, 0), points); 90 | 91 | NSInteger numLines = CFArrayGetCount(lines); 92 | // for each LINE 93 | for (CFIndex lineIndex = 0; lineIndex < numLines; lineIndex++) 94 | { 95 | CTLineRef lineRef = CFArrayGetValueAtIndex(lines, lineIndex); 96 | 97 | CFRange r = CTLineGetStringRange(lineRef); 98 | 99 | NSParagraphStyle *paragraphStyle = [attrString attribute:NSParagraphStyleAttributeName atIndex:r.location effectiveRange:NULL]; 100 | NSTextAlignment alignment = paragraphStyle.alignment; 101 | 102 | 103 | CGFloat flushFactor = 0.0; 104 | if (alignment == NSTextAlignmentLeft) { 105 | flushFactor = 0.0; 106 | } else if (alignment == NSTextAlignmentCenter) { 107 | flushFactor = 0.5; 108 | } else if (alignment == NSTextAlignmentRight) { 109 | flushFactor = 1.0; 110 | } 111 | 112 | 113 | 114 | CGFloat penOffset = CTLineGetPenOffsetForFlush(lineRef, flushFactor, maxWidth); 115 | 116 | // create a new justified line if the alignment is justified 117 | if (alignment == NSTextAlignmentJustified) { 118 | lineRef = CTLineCreateJustifiedLine(lineRef, 1.0, maxWidth); 119 | penOffset = 0; 120 | } 121 | 122 | CGFloat lineOffset = numLines == 1 ? 0 : maxHeight - points[lineIndex].y; 123 | 124 | CFArrayRef runArray = CTLineGetGlyphRuns(lineRef); 125 | 126 | // for each RUN 127 | for (CFIndex runIndex = 0; runIndex < CFArrayGetCount(runArray); runIndex++) 128 | { 129 | // Get FONT for this run 130 | CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runArray, runIndex); 131 | CTFontRef runFont = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName); 132 | 133 | // for each GLYPH in run 134 | for (CFIndex runGlyphIndex = 0; runGlyphIndex < CTRunGetGlyphCount(run); runGlyphIndex++) 135 | { 136 | // get Glyph & Glyph-data 137 | CFRange thisGlyphRange = CFRangeMake(runGlyphIndex, 1); 138 | CGGlyph glyph; 139 | CGPoint position; 140 | CTRunGetGlyphs(run, thisGlyphRange, &glyph); 141 | CTRunGetPositions(run, thisGlyphRange, &position); 142 | 143 | position.y -= lineOffset; 144 | position.x += penOffset; 145 | 146 | CGPathRef letter = CTFontCreatePathForGlyph(runFont, glyph, NULL); 147 | CGAffineTransform t = CGAffineTransformMakeTranslation(position.x, position.y); 148 | CGPathAddPath(letters, &t, letter); 149 | CGPathRelease(letter); 150 | } 151 | } 152 | 153 | // if the text is justified then release the new justified line we created. 154 | if (alignment == NSTextAlignmentJustified) { 155 | CFRelease(lineRef); 156 | } 157 | } 158 | 159 | free(points); 160 | 161 | CGPathRelease(pathRef); 162 | CFRelease(frame); 163 | CFRelease(framesetter); 164 | 165 | CGRect pathBounds = CGPathGetBoundingBox(letters); 166 | CGAffineTransform transform = CGAffineTransformMakeTranslation(-pathBounds.origin.x, -pathBounds.origin.y); 167 | CGPathRef finalPath = CGPathCreateCopyByTransformingPath(letters, &transform); 168 | CGPathRelease(letters); 169 | 170 | return finalPath; 171 | } 172 | -------------------------------------------------------------------------------- /ARCGPathFromString/UIBezierPath+TextPaths.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBezierPath+TextPaths.h 3 | // 4 | // Created by Adrian Russell on 11/10/2012. 5 | // Copyright (c) 2014 Adrian Russell. All rights reserved. 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. Permission is granted to anyone to 10 | // use this software for any purpose, including commercial applications, and to 11 | // alter it and redistribute it freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would be 16 | // appreciated but is not required. 17 | // 2. Altered source versions must be plainly marked as such, and must not be 18 | // misrepresented as being the original software. 19 | // 3. This notice may not be removed or altered from any source 20 | // distribution. 21 | // 22 | 23 | #import 24 | 25 | NS_ASSUME_NONNULL_BEGIN 26 | 27 | /** 28 | Adds methods which will create paths from attributed strings. 29 | These methods wrap the functions defined in `ARCGPathFromString.h`. 30 | */ 31 | @interface UIBezierPath (TextPaths) 32 | 33 | /** @name Path from NSString */ 34 | 35 | /** 36 | Create a bezier path for a specified string rendered with a specified font. 37 | @param string The string to produce the path for. Must not be `nil`. An empty string will produce an empty bezier path. 38 | @param font The font to use for producing the string glyphs. Must not be `nil`. 39 | @return A `UIBezierPath` that contains a path with paths for all the glyphs for specifed string. 40 | @discussion If the string contains any newline characters they will be ignored and the string will be rendered on a single line. 41 | */ 42 | + (UIBezierPath *)pathForString:(NSString *)string 43 | withFont:(UIFont *)font; 44 | 45 | /** 46 | Create a bezier path for a specified string that consumes multiple lines rendered with a specified font. 47 | @param string The string to produce the path for. Must not be `nil`. An empty string will produce an empty bezier path. 48 | @param font The font to use for producing the string glyphs. Must not be `nil`. 49 | @param maxWidth The maximum width of a line, if a line when rendered is longer than this width then the line is broken to a new line. Must be greater than 0. 50 | @param alignment The alignment of text. This method supports Left, Center, Right & Justified alignment; Natural will be treated as Left. 51 | @return A `UIBezierPath` that contains a path with paths for all the glyphs for specifed string. 52 | */ 53 | + (UIBezierPath *)pathForMultilineString:(NSString *)string 54 | withFont:(UIFont *)font 55 | maxWidth:(CGFloat)maxWidth 56 | textAlignment:(NSTextAlignment)alignment; 57 | 58 | 59 | 60 | /** @name Path from NSAttributedString */ 61 | 62 | /** 63 | Create a bezier path for a specified attributed string. 64 | @param string The string to produce the path for. Must not be `nil`. An empty string will produce an empty bezier path. 65 | @return A `UIBezierPath` that contains a path with paths for all the glyphs for specifed string. If the input string is `nil` then `nil` is returned. 66 | @discussion If the string contains any newline characters they will be ignored and the string will be rendered on a single line. 67 | */ 68 | + (UIBezierPath *)pathForAttributedString:(NSAttributedString *)string; 69 | 70 | 71 | /** 72 | Create a bezier path for a specified attributed string that consumes multiple lines. 73 | @param string The string to produce the path for. Must not be `nil`. An empty string will produce an empty bezier path. 74 | @param maxWidth The maximum width of a line, if a line when rendered is longer than this width then the line is broken to a new line. Must be greater than 0. 75 | @return A `UIBezierPath` that contains a path with paths for all the glyphs for specifed string. 76 | */ 77 | + (UIBezierPath *)pathForMultilineAttributedString:(NSAttributedString *)string 78 | maxWidth:(CGFloat)maxWidth; 79 | 80 | @end 81 | 82 | NS_ASSUME_NONNULL_END 83 | -------------------------------------------------------------------------------- /ARCGPathFromString/UIBezierPath+TextPaths.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBezierPath+TextPaths.m 3 | // 4 | // Created by Adrian Russell on 11/10/2012. 5 | // Copyright (c) 2014 Adrian Russell. All rights reserved. 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. Permission is granted to anyone to 10 | // use this software for any purpose, including commercial applications, and to 11 | // alter it and redistribute it freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would be 16 | // appreciated but is not required. 17 | // 2. Altered source versions must be plainly marked as such, and must not be 18 | // misrepresented as being the original software. 19 | // 3. This notice may not be removed or altered from any source 20 | // distribution. 21 | // 22 | 23 | #import "UIBezierPath+TextPaths.h" 24 | #import "ARCGPathFromString.h" 25 | 26 | 27 | // for the multiline the CTFrame must have a max path size. This value is arbitrary, currently 4x the height of ipad screen. 28 | #define MAX_HEIGHT_OF_FRAME 4096 29 | 30 | 31 | 32 | 33 | @implementation UIBezierPath (TextPaths) 34 | 35 | 36 | #pragma mark - NSString 37 | 38 | 39 | + (UIBezierPath *)pathForString:(NSString *)string withFont:(UIFont *)font 40 | { 41 | // if there is no string or font then just return nil. 42 | if (!string || !font) return [UIBezierPath bezierPath]; 43 | 44 | // create the dictionary of attributes for the attributed string contaning the font. 45 | NSDictionary *attributes = @{ NSFontAttributeName : font }; 46 | 47 | // create the attributed string. 48 | NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:string attributes:attributes]; 49 | 50 | // create path from attributed string. 51 | return [self pathForAttributedString:attrString]; 52 | } 53 | 54 | 55 | + (UIBezierPath *)pathForMultilineString:(NSString *)string 56 | withFont:(UIFont *)font 57 | maxWidth:(CGFloat)maxWidth 58 | textAlignment:(NSTextAlignment)alignment 59 | 60 | { 61 | // if there is no string or font or no width then just return nil. 62 | if (!string || !font || maxWidth <= 0.0) return [UIBezierPath bezierPath]; 63 | 64 | // create the paragraph style so the text alignment can be assigned to the attributed string. 65 | NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; 66 | paragraphStyle.alignment = alignment; 67 | 68 | // create the dictionary of attributes for the attributed string contaning the font and the paragraph style with the text alignment. 69 | NSDictionary *attributes = @{ NSFontAttributeName : font, NSParagraphStyleAttributeName : paragraphStyle }; 70 | 71 | // create the attributed string. 72 | NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:string attributes:attributes]; 73 | 74 | // create path for attributed string. 75 | return [self pathForMultilineAttributedString:attrString maxWidth:maxWidth]; 76 | } 77 | 78 | 79 | #pragma mark - NSAttributedString 80 | 81 | 82 | + (UIBezierPath *)pathForAttributedString:(NSAttributedString *)string 83 | { 84 | // if there is no specified string then there will be no path so just return nil. 85 | if (!string) return [UIBezierPath bezierPath]; 86 | 87 | // create the path from the specified string. 88 | CGPathRef letters = CGPathCreateSingleLineStringWithAttributedString(string); 89 | 90 | // make an iOS UIBezierPath object from the CGPath. 91 | UIBezierPath *path = [UIBezierPath bezierPathWithCGPath:letters]; 92 | 93 | // release the created CGPath. 94 | CGPathRelease(letters); 95 | 96 | return path; 97 | } 98 | 99 | 100 | + (UIBezierPath *)pathForMultilineAttributedString:(NSAttributedString *)string maxWidth:(CGFloat)maxWidth 101 | { 102 | // if there is no specified string or the maxwidth is set to 0 then there will be no path so return nil. 103 | if (!string || maxWidth <= 0.0) return [UIBezierPath bezierPath]; 104 | 105 | // create the path from the specified string. 106 | CGPathRef letters = CGPathCreateMultilineStringWithAttributedString(string, maxWidth, MAX_HEIGHT_OF_FRAME); 107 | 108 | // make an iOS UIBezierPath object from the CGPath. 109 | UIBezierPath *path = [UIBezierPath bezierPathWithCGPath:letters]; 110 | 111 | // release the created CGPath. 112 | CGPathRelease(letters); 113 | 114 | return path; 115 | } 116 | 117 | 118 | 119 | 120 | 121 | @end 122 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | 2 | 1.1.0 (31/12/2017) 3 | --------------------- 4 | 5 | #### Changed 6 | * Added some function annotations to make the function play nicer with projects using Swift. 7 | * Methods passed `nil` as the string input parameter will now return an empty path rather than `nil`. 8 | 9 | 10 | 11 | 1.0.0 (11/08/2014) 12 | --------------------- 13 | 14 | #### Added 15 | * The multiline methods now support justified text alignment. (Note that natural aligment is still not supported; they will be left aligned if used.) 16 | 17 | #### Changed 18 | * All the method names have been changed to make them clearer. 19 | * The CoreText internals have been seperated out from the UIBezierPath category, this means that OS X can now use the CoreText methods which return a `CGPathRef`. 20 | 21 | 22 | 23 | 0.0.0 (8/8/2014) 24 | ------------------ 25 | Initial Release 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Adrian Russell 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 category for UIBezierPath that add methods which will create a path for a specified NSAttributedString. 2 | For use with iOS 6 and later. 3 | 4 | ## Installing the project 5 | `pod 'ARCGPathFromString'` 6 | 7 | 8 | 9 | ## Creating a path from an NSString 10 | You can create paths for single line NSStrings by specifying the font to use. 11 | 12 | `+ (UIBezierPath *)pathForString:(NSString *)string withFont:(UIFont *)font` 13 | 14 | 15 | The multi line method also requires the text alignment (can be left, right, center, or justified) and a maximum width for each line of text. 16 | 17 | `+ (UIBezierPath *)pathForMultilineString:(NSString *)string withFont:(UIFont *)font maxWidth:(CGFloat)maxWidth textAlignment:(NSTextAlignment)alignment` 18 | 19 | 20 | 21 | ## Creating a path from an NSAttributedString 22 | You can also create paths for single line NSAttributedStrings 23 | 24 | `+ (UIBezierPath *)pathForAttributedString:(NSAttributedString *)string` 25 | 26 | The multi line method also requires a maximum width for each line of text. 27 | 28 | `+ (UIBezierPath *)pathForMultilineAttributedString:(NSAttributedString *)string maxWidth:(CGFloat)maxWidth` 29 | 30 | 31 | 32 | ## License 33 | ARCGPathFromString is available under the MIT license. See the LICENSE file for more info. 34 | -------------------------------------------------------------------------------- /Text2CGPathDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | AB6840F5166E773D001E7689 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB6840F4166E773D001E7689 /* UIKit.framework */; }; 11 | AB6840F7166E773D001E7689 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB6840F6166E773D001E7689 /* Foundation.framework */; }; 12 | AB6840F9166E773D001E7689 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB6840F8166E773D001E7689 /* CoreGraphics.framework */; }; 13 | AB6840FF166E773D001E7689 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AB6840FD166E773D001E7689 /* InfoPlist.strings */; }; 14 | AB684101166E773D001E7689 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AB684100166E773D001E7689 /* main.m */; }; 15 | AB684105166E773D001E7689 /* ARAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AB684104166E773D001E7689 /* ARAppDelegate.m */; }; 16 | AB684107166E773D001E7689 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = AB684106166E773D001E7689 /* Default.png */; }; 17 | AB684109166E773D001E7689 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = AB684108166E773D001E7689 /* Default@2x.png */; }; 18 | AB68410B166E773D001E7689 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = AB68410A166E773D001E7689 /* Default-568h@2x.png */; }; 19 | AB68410E166E773D001E7689 /* MainStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB68410C166E773D001E7689 /* MainStoryboard.storyboard */; }; 20 | AB684111166E773D001E7689 /* ARViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB684110166E773D001E7689 /* ARViewController.m */; }; 21 | AB684118166E87B3001E7689 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB684117166E87B3001E7689 /* QuartzCore.framework */; }; 22 | AB68411B166E89E0001E7689 /* UIBezierPath+TextPaths.m in Sources */ = {isa = PBXBuildFile; fileRef = AB68411A166E89E0001E7689 /* UIBezierPath+TextPaths.m */; }; 23 | AB68411D166E90D2001E7689 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB68411C166E90D2001E7689 /* CoreText.framework */; }; 24 | ABBB133D261517B20020B371 /* SwiftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABBB133C261517B20020B371 /* SwiftViewController.swift */; }; 25 | ABBC8C8519952C34008F3153 /* ARCGPathFromString.m in Sources */ = {isa = PBXBuildFile; fileRef = ABBC8C8419952C34008F3153 /* ARCGPathFromString.m */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | AB6840F0166E773D001E7689 /* Text2CGPathDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Text2CGPathDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | AB6840F4166E773D001E7689 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 31 | AB6840F6166E773D001E7689 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 32 | AB6840F8166E773D001E7689 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 33 | AB6840FC166E773D001E7689 /* Text2CGPathDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Text2CGPathDemo-Info.plist"; sourceTree = ""; }; 34 | AB6840FE166E773D001E7689 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 35 | AB684100166E773D001E7689 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 36 | AB684102166E773D001E7689 /* Text2CGPathDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Text2CGPathDemo-Prefix.pch"; sourceTree = ""; }; 37 | AB684103166E773D001E7689 /* ARAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ARAppDelegate.h; sourceTree = ""; }; 38 | AB684104166E773D001E7689 /* ARAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARAppDelegate.m; sourceTree = ""; }; 39 | AB684106166E773D001E7689 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 40 | AB684108166E773D001E7689 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 41 | AB68410A166E773D001E7689 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 42 | AB68410F166E773D001E7689 /* ARViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ARViewController.h; sourceTree = ""; }; 43 | AB684110166E773D001E7689 /* ARViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARViewController.m; sourceTree = ""; }; 44 | AB684117166E87B3001E7689 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 45 | AB684119166E89E0001E7689 /* UIBezierPath+TextPaths.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIBezierPath+TextPaths.h"; path = "../ARCGPathFromString/UIBezierPath+TextPaths.h"; sourceTree = ""; }; 46 | AB68411A166E89E0001E7689 /* UIBezierPath+TextPaths.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIBezierPath+TextPaths.m"; path = "../ARCGPathFromString/UIBezierPath+TextPaths.m"; sourceTree = ""; }; 47 | AB68411C166E90D2001E7689 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; 48 | ABBB133B261517B10020B371 /* Text2CGPathDemo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Text2CGPathDemo-Bridging-Header.h"; sourceTree = ""; }; 49 | ABBB133C261517B20020B371 /* SwiftViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftViewController.swift; sourceTree = ""; }; 50 | ABBB133F26151E2E0020B371 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainStoryboard.storyboard; sourceTree = ""; }; 51 | ABBC8C8319952C34008F3153 /* ARCGPathFromString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ARCGPathFromString.h; sourceTree = ""; }; 52 | ABBC8C8419952C34008F3153 /* ARCGPathFromString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARCGPathFromString.m; sourceTree = ""; }; 53 | /* End PBXFileReference section */ 54 | 55 | /* Begin PBXFrameworksBuildPhase section */ 56 | AB6840ED166E773D001E7689 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | AB68411D166E90D2001E7689 /* CoreText.framework in Frameworks */, 61 | AB684118166E87B3001E7689 /* QuartzCore.framework in Frameworks */, 62 | AB6840F5166E773D001E7689 /* UIKit.framework in Frameworks */, 63 | AB6840F7166E773D001E7689 /* Foundation.framework in Frameworks */, 64 | AB6840F9166E773D001E7689 /* CoreGraphics.framework in Frameworks */, 65 | ); 66 | runOnlyForDeploymentPostprocessing = 0; 67 | }; 68 | /* End PBXFrameworksBuildPhase section */ 69 | 70 | /* Begin PBXGroup section */ 71 | AB6840E5166E773C001E7689 = { 72 | isa = PBXGroup; 73 | children = ( 74 | ABBC8C8219952BC7008F3153 /* ARCGPathFromString */, 75 | AB6840FA166E773D001E7689 /* Text2CGPathDemo */, 76 | AB6840F3166E773D001E7689 /* Frameworks */, 77 | AB6840F1166E773D001E7689 /* Products */, 78 | ); 79 | sourceTree = ""; 80 | }; 81 | AB6840F1166E773D001E7689 /* Products */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | AB6840F0166E773D001E7689 /* Text2CGPathDemo.app */, 85 | ); 86 | name = Products; 87 | sourceTree = ""; 88 | }; 89 | AB6840F3166E773D001E7689 /* Frameworks */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | AB68411C166E90D2001E7689 /* CoreText.framework */, 93 | AB684117166E87B3001E7689 /* QuartzCore.framework */, 94 | AB6840F4166E773D001E7689 /* UIKit.framework */, 95 | AB6840F6166E773D001E7689 /* Foundation.framework */, 96 | AB6840F8166E773D001E7689 /* CoreGraphics.framework */, 97 | ); 98 | name = Frameworks; 99 | sourceTree = ""; 100 | }; 101 | AB6840FA166E773D001E7689 /* Text2CGPathDemo */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | AB684103166E773D001E7689 /* ARAppDelegate.h */, 105 | AB684104166E773D001E7689 /* ARAppDelegate.m */, 106 | AB68410C166E773D001E7689 /* MainStoryboard.storyboard */, 107 | AB68410F166E773D001E7689 /* ARViewController.h */, 108 | AB684110166E773D001E7689 /* ARViewController.m */, 109 | ABBB133C261517B20020B371 /* SwiftViewController.swift */, 110 | AB6840FB166E773D001E7689 /* Supporting Files */, 111 | ABBB133B261517B10020B371 /* Text2CGPathDemo-Bridging-Header.h */, 112 | ); 113 | path = Text2CGPathDemo; 114 | sourceTree = ""; 115 | }; 116 | AB6840FB166E773D001E7689 /* Supporting Files */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | AB6840FC166E773D001E7689 /* Text2CGPathDemo-Info.plist */, 120 | AB6840FD166E773D001E7689 /* InfoPlist.strings */, 121 | AB684100166E773D001E7689 /* main.m */, 122 | AB684102166E773D001E7689 /* Text2CGPathDemo-Prefix.pch */, 123 | AB684106166E773D001E7689 /* Default.png */, 124 | AB684108166E773D001E7689 /* Default@2x.png */, 125 | AB68410A166E773D001E7689 /* Default-568h@2x.png */, 126 | ); 127 | name = "Supporting Files"; 128 | sourceTree = ""; 129 | }; 130 | ABBC8C8219952BC7008F3153 /* ARCGPathFromString */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | AB684119166E89E0001E7689 /* UIBezierPath+TextPaths.h */, 134 | AB68411A166E89E0001E7689 /* UIBezierPath+TextPaths.m */, 135 | ABBC8C8319952C34008F3153 /* ARCGPathFromString.h */, 136 | ABBC8C8419952C34008F3153 /* ARCGPathFromString.m */, 137 | ); 138 | path = ARCGPathFromString; 139 | sourceTree = ""; 140 | }; 141 | /* End PBXGroup section */ 142 | 143 | /* Begin PBXNativeTarget section */ 144 | AB6840EF166E773D001E7689 /* Text2CGPathDemo */ = { 145 | isa = PBXNativeTarget; 146 | buildConfigurationList = AB684114166E773D001E7689 /* Build configuration list for PBXNativeTarget "Text2CGPathDemo" */; 147 | buildPhases = ( 148 | AB6840EC166E773D001E7689 /* Sources */, 149 | AB6840ED166E773D001E7689 /* Frameworks */, 150 | AB6840EE166E773D001E7689 /* Resources */, 151 | ); 152 | buildRules = ( 153 | ); 154 | dependencies = ( 155 | ); 156 | name = Text2CGPathDemo; 157 | productName = Text2CGPathDemo; 158 | productReference = AB6840F0166E773D001E7689 /* Text2CGPathDemo.app */; 159 | productType = "com.apple.product-type.application"; 160 | }; 161 | /* End PBXNativeTarget section */ 162 | 163 | /* Begin PBXProject section */ 164 | AB6840E7166E773D001E7689 /* Project object */ = { 165 | isa = PBXProject; 166 | attributes = { 167 | CLASSPREFIX = AR; 168 | LastUpgradeCheck = 1010; 169 | ORGANIZATIONNAME = "Adrian Russell"; 170 | TargetAttributes = { 171 | AB6840EF166E773D001E7689 = { 172 | LastSwiftMigration = 1230; 173 | }; 174 | }; 175 | }; 176 | buildConfigurationList = AB6840EA166E773D001E7689 /* Build configuration list for PBXProject "Text2CGPathDemo" */; 177 | compatibilityVersion = "Xcode 3.2"; 178 | developmentRegion = en; 179 | hasScannedForEncodings = 0; 180 | knownRegions = ( 181 | en, 182 | Base, 183 | ); 184 | mainGroup = AB6840E5166E773C001E7689; 185 | productRefGroup = AB6840F1166E773D001E7689 /* Products */; 186 | projectDirPath = ""; 187 | projectRoot = ""; 188 | targets = ( 189 | AB6840EF166E773D001E7689 /* Text2CGPathDemo */, 190 | ); 191 | }; 192 | /* End PBXProject section */ 193 | 194 | /* Begin PBXResourcesBuildPhase section */ 195 | AB6840EE166E773D001E7689 /* Resources */ = { 196 | isa = PBXResourcesBuildPhase; 197 | buildActionMask = 2147483647; 198 | files = ( 199 | AB6840FF166E773D001E7689 /* InfoPlist.strings in Resources */, 200 | AB684107166E773D001E7689 /* Default.png in Resources */, 201 | AB684109166E773D001E7689 /* Default@2x.png in Resources */, 202 | AB68410B166E773D001E7689 /* Default-568h@2x.png in Resources */, 203 | AB68410E166E773D001E7689 /* MainStoryboard.storyboard in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXResourcesBuildPhase section */ 208 | 209 | /* Begin PBXSourcesBuildPhase section */ 210 | AB6840EC166E773D001E7689 /* Sources */ = { 211 | isa = PBXSourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | ABBB133D261517B20020B371 /* SwiftViewController.swift in Sources */, 215 | AB684101166E773D001E7689 /* main.m in Sources */, 216 | ABBC8C8519952C34008F3153 /* ARCGPathFromString.m in Sources */, 217 | AB684105166E773D001E7689 /* ARAppDelegate.m in Sources */, 218 | AB684111166E773D001E7689 /* ARViewController.m in Sources */, 219 | AB68411B166E89E0001E7689 /* UIBezierPath+TextPaths.m in Sources */, 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | /* End PBXSourcesBuildPhase section */ 224 | 225 | /* Begin PBXVariantGroup section */ 226 | AB6840FD166E773D001E7689 /* InfoPlist.strings */ = { 227 | isa = PBXVariantGroup; 228 | children = ( 229 | AB6840FE166E773D001E7689 /* en */, 230 | ); 231 | name = InfoPlist.strings; 232 | sourceTree = ""; 233 | }; 234 | AB68410C166E773D001E7689 /* MainStoryboard.storyboard */ = { 235 | isa = PBXVariantGroup; 236 | children = ( 237 | ABBB133F26151E2E0020B371 /* Base */, 238 | ); 239 | name = MainStoryboard.storyboard; 240 | sourceTree = ""; 241 | }; 242 | /* End PBXVariantGroup section */ 243 | 244 | /* Begin XCBuildConfiguration section */ 245 | AB684112166E773D001E7689 /* Debug */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 250 | CLANG_CXX_LIBRARY = "libc++"; 251 | CLANG_ENABLE_OBJC_ARC = YES; 252 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 253 | CLANG_WARN_BOOL_CONVERSION = YES; 254 | CLANG_WARN_COMMA = YES; 255 | CLANG_WARN_CONSTANT_CONVERSION = YES; 256 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 257 | CLANG_WARN_EMPTY_BODY = YES; 258 | CLANG_WARN_ENUM_CONVERSION = YES; 259 | CLANG_WARN_INFINITE_RECURSION = YES; 260 | CLANG_WARN_INT_CONVERSION = YES; 261 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 262 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 263 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 264 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 265 | CLANG_WARN_STRICT_PROTOTYPES = YES; 266 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 267 | CLANG_WARN_UNREACHABLE_CODE = YES; 268 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 269 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 270 | COPY_PHASE_STRIP = NO; 271 | ENABLE_STRICT_OBJC_MSGSEND = YES; 272 | ENABLE_TESTABILITY = YES; 273 | GCC_C_LANGUAGE_STANDARD = gnu99; 274 | GCC_DYNAMIC_NO_PIC = NO; 275 | GCC_NO_COMMON_BLOCKS = YES; 276 | GCC_OPTIMIZATION_LEVEL = 0; 277 | GCC_PREPROCESSOR_DEFINITIONS = ( 278 | "DEBUG=1", 279 | "$(inherited)", 280 | ); 281 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 282 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 283 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 284 | GCC_WARN_UNDECLARED_SELECTOR = YES; 285 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 286 | GCC_WARN_UNUSED_FUNCTION = YES; 287 | GCC_WARN_UNUSED_VARIABLE = YES; 288 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 289 | ONLY_ACTIVE_ARCH = YES; 290 | SDKROOT = iphoneos; 291 | TARGETED_DEVICE_FAMILY = 2; 292 | }; 293 | name = Debug; 294 | }; 295 | AB684113166E773D001E7689 /* Release */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ALWAYS_SEARCH_USER_PATHS = NO; 299 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 300 | CLANG_CXX_LIBRARY = "libc++"; 301 | CLANG_ENABLE_OBJC_ARC = YES; 302 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 303 | CLANG_WARN_BOOL_CONVERSION = YES; 304 | CLANG_WARN_COMMA = YES; 305 | CLANG_WARN_CONSTANT_CONVERSION = YES; 306 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 307 | CLANG_WARN_EMPTY_BODY = YES; 308 | CLANG_WARN_ENUM_CONVERSION = YES; 309 | CLANG_WARN_INFINITE_RECURSION = YES; 310 | CLANG_WARN_INT_CONVERSION = YES; 311 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 312 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 313 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 314 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 315 | CLANG_WARN_STRICT_PROTOTYPES = YES; 316 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 317 | CLANG_WARN_UNREACHABLE_CODE = YES; 318 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 319 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 320 | COPY_PHASE_STRIP = YES; 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; 326 | GCC_WARN_UNDECLARED_SELECTOR = YES; 327 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 328 | GCC_WARN_UNUSED_FUNCTION = YES; 329 | GCC_WARN_UNUSED_VARIABLE = YES; 330 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 331 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 332 | SDKROOT = iphoneos; 333 | TARGETED_DEVICE_FAMILY = 2; 334 | VALIDATE_PRODUCT = YES; 335 | }; 336 | name = Release; 337 | }; 338 | AB684115166E773D001E7689 /* Debug */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | CLANG_ENABLE_MODULES = YES; 342 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 343 | GCC_PREFIX_HEADER = "Text2CGPathDemo/Text2CGPathDemo-Prefix.pch"; 344 | INFOPLIST_FILE = "Text2CGPathDemo/Text2CGPathDemo-Info.plist"; 345 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 346 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 347 | PRODUCT_BUNDLE_IDENTIFIER = "co.uk.adrianrussell.${PRODUCT_NAME:rfc1034identifier}"; 348 | PRODUCT_NAME = "$(TARGET_NAME)"; 349 | SWIFT_OBJC_BRIDGING_HEADER = "Text2CGPathDemo/Text2CGPathDemo-Bridging-Header.h"; 350 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 351 | SWIFT_VERSION = 5.0; 352 | WRAPPER_EXTENSION = app; 353 | }; 354 | name = Debug; 355 | }; 356 | AB684116166E773D001E7689 /* Release */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | CLANG_ENABLE_MODULES = YES; 360 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 361 | GCC_PREFIX_HEADER = "Text2CGPathDemo/Text2CGPathDemo-Prefix.pch"; 362 | INFOPLIST_FILE = "Text2CGPathDemo/Text2CGPathDemo-Info.plist"; 363 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 364 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 365 | PRODUCT_BUNDLE_IDENTIFIER = "co.uk.adrianrussell.${PRODUCT_NAME:rfc1034identifier}"; 366 | PRODUCT_NAME = "$(TARGET_NAME)"; 367 | SWIFT_OBJC_BRIDGING_HEADER = "Text2CGPathDemo/Text2CGPathDemo-Bridging-Header.h"; 368 | SWIFT_VERSION = 5.0; 369 | WRAPPER_EXTENSION = app; 370 | }; 371 | name = Release; 372 | }; 373 | /* End XCBuildConfiguration section */ 374 | 375 | /* Begin XCConfigurationList section */ 376 | AB6840EA166E773D001E7689 /* Build configuration list for PBXProject "Text2CGPathDemo" */ = { 377 | isa = XCConfigurationList; 378 | buildConfigurations = ( 379 | AB684112166E773D001E7689 /* Debug */, 380 | AB684113166E773D001E7689 /* Release */, 381 | ); 382 | defaultConfigurationIsVisible = 0; 383 | defaultConfigurationName = Release; 384 | }; 385 | AB684114166E773D001E7689 /* Build configuration list for PBXNativeTarget "Text2CGPathDemo" */ = { 386 | isa = XCConfigurationList; 387 | buildConfigurations = ( 388 | AB684115166E773D001E7689 /* Debug */, 389 | AB684116166E773D001E7689 /* Release */, 390 | ); 391 | defaultConfigurationIsVisible = 0; 392 | defaultConfigurationName = Release; 393 | }; 394 | /* End XCConfigurationList section */ 395 | }; 396 | rootObject = AB6840E7166E773D001E7689 /* Project object */; 397 | } 398 | -------------------------------------------------------------------------------- /Text2CGPathDemo/ARAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARAppDelegate.h 3 | // Text2CGPathDemo 4 | // 5 | // Created by Adrian Russell on 12/4/12. 6 | // Copyright (c) 2012 Adrian Russell. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ARAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Text2CGPathDemo/ARAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARAppDelegate.m 3 | // Text2CGPathDemo 4 | // 5 | // Created by Adrian Russell on 12/4/12. 6 | // Copyright (c) 2012 Adrian Russell. All rights reserved. 7 | // 8 | 9 | #import "ARAppDelegate.h" 10 | 11 | @implementation ARAppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // 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. 22 | // 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. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // 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. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // 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. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 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 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Text2CGPathDemo/ARViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ARViewController.h 3 | // Text2CGPathDemo 4 | // 5 | // Created by Adrian Russell on 12/4/12. 6 | // Copyright (c) 2012 Adrian Russell. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ARViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Text2CGPathDemo/ARViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ARViewController.m 3 | // Text2CGPathDemo 4 | // 5 | // Created by Adrian Russell on 12/4/12. 6 | // Copyright (c) 2012 Adrian Russell. All rights reserved. 7 | // 8 | 9 | #import "ARViewController.h" 10 | #import "UIBezierPath+TextPaths.h" 11 | #import 12 | 13 | //----------------------------------------------------- 14 | #pragma mark - Constants 15 | 16 | #define SINGLE_LINE_STRING @"Single line path." 17 | #define MULTI_LINE_STRING @"Multi-line string that doesn't have a newline character so is automatically lined to fit width." 18 | #define MULTI_LINE_STRING_LINE_BREAKS @"Multi-line string\nwith '\\n' characters\nto\nforce\nnew line." 19 | 20 | 21 | 22 | static NSString *const kFonts[4] = { @"Helvetica-Bold", @"AmericanTypewriter-CondensedLight", @"MarkerFelt-Thin", @"TimesNewRomanPS-ItalicMT" }; 23 | static CGFloat kFontsizes[4] = { 30.0, 60.0, 50.0, 40.0}; 24 | 25 | 26 | //----------------------------------------------------- 27 | #pragma mark - Class implementation 28 | 29 | @implementation ARViewController 30 | 31 | - (void)viewDidLoad 32 | { 33 | [super viewDidLoad]; 34 | self.view.backgroundColor = [UIColor colorWithRed:0.78 green:0.90 blue:0.91 alpha:1.0]; 35 | // Do any additional setup after loading the view, typically from a nib. 36 | } 37 | 38 | - (NSAttributedString *)attributedStringForString:(NSString *)string 39 | { 40 | NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:string]; 41 | 42 | for (NSUInteger i = 0; i < string.length; i++) { 43 | NSUInteger option = (i % 4); 44 | UIFont *font = [UIFont fontWithName:kFonts[option] size:kFontsizes[option]]; 45 | [attString addAttribute:NSFontAttributeName value:font range:NSMakeRange(i, 1)]; 46 | } 47 | 48 | return [attString copy]; 49 | } 50 | 51 | 52 | - (CAShapeLayer *)singleLinePathStandard 53 | { 54 | CAShapeLayer *line1 = [CAShapeLayer new]; 55 | line1.path = [UIBezierPath pathForString:SINGLE_LINE_STRING withFont:[UIFont boldSystemFontOfSize:60.0]].CGPath; 56 | line1.bounds = CGPathGetBoundingBox(line1.path); 57 | line1.geometryFlipped = YES; 58 | line1.fillColor = [UIColor whiteColor].CGColor; 59 | line1.strokeColor = [UIColor blackColor].CGColor; 60 | line1.lineWidth = 1.0; 61 | 62 | return line1; 63 | } 64 | 65 | - (CAShapeLayer *)singleLinePathAttributed 66 | { 67 | NSAttributedString *attString = [self attributedStringForString:SINGLE_LINE_STRING]; 68 | 69 | CAShapeLayer *line1 = [CAShapeLayer new]; 70 | line1.path = [UIBezierPath pathForAttributedString:attString].CGPath; 71 | line1.bounds = CGPathGetBoundingBox(line1.path); 72 | line1.geometryFlipped = YES; 73 | line1.fillColor = [UIColor whiteColor].CGColor; 74 | line1.strokeColor = [UIColor blackColor].CGColor; 75 | line1.lineWidth = 1.0; 76 | 77 | return line1; 78 | } 79 | 80 | - (CAShapeLayer *)multiLinePathAttributed 81 | { 82 | NSAttributedString *attrString2 = [self attributedStringForString:MULTI_LINE_STRING]; 83 | 84 | NSMutableAttributedString *mutAttr = [attrString2 mutableCopy]; 85 | NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; 86 | paragraphStyle.alignment = NSTextAlignmentJustified; 87 | [mutAttr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attrString2.length)]; 88 | 89 | 90 | CAShapeLayer *line2 = [CAShapeLayer new]; 91 | line2.path = [UIBezierPath pathForMultilineAttributedString:mutAttr maxWidth:self.view.bounds.size.width - 100].CGPath; 92 | line2.bounds = CGPathGetBoundingBox(line2.path); 93 | line2.geometryFlipped = YES; 94 | line2.fillColor = [UIColor whiteColor].CGColor; 95 | line2.strokeColor = [UIColor blackColor].CGColor; 96 | line2.lineWidth = 1.0; 97 | 98 | return line2; 99 | } 100 | 101 | - (CAShapeLayer *)multiLinePathStandardLineBreaks 102 | { 103 | CAShapeLayer *line3 = [CAShapeLayer new]; 104 | line3.path = [UIBezierPath pathForMultilineString:MULTI_LINE_STRING_LINE_BREAKS 105 | withFont:[UIFont boldSystemFontOfSize:40.0] 106 | maxWidth:self.view.bounds.size.width - 100 107 | textAlignment:NSTextAlignmentCenter].CGPath; 108 | line3.bounds = CGPathGetBoundingBox(line3.path); 109 | line3.geometryFlipped = YES; 110 | line3.fillColor = [UIColor whiteColor].CGColor; 111 | line3.strokeColor = [UIColor blackColor].CGColor; 112 | line3.lineWidth = 1.0; 113 | 114 | return line3; 115 | } 116 | 117 | 118 | //------------------------------------------------------------------------------- 119 | 120 | - (void)viewDidAppear:(BOOL)animated 121 | { 122 | [super viewDidAppear:animated]; 123 | 124 | // load single with standard string 125 | CAShapeLayer *line1 = [self singleLinePathStandard]; 126 | line1.position = CGPointMake(self.view.bounds.size.width / 2.0, self.view.bounds.size.height * 0.10); 127 | [self.view.layer addSublayer:line1]; 128 | 129 | // load single with attributed string 130 | CAShapeLayer *line2 = [self singleLinePathAttributed]; 131 | line2.position = CGPointMake(self.view.bounds.size.width / 2.0, self.view.bounds.size.height * 0.25); 132 | [self.view.layer addSublayer:line2]; 133 | 134 | // load multi with attributed string 135 | CAShapeLayer *line3 = [self multiLinePathAttributed]; 136 | line3.position = CGPointMake(self.view.bounds.size.width / 2.0, self.view.bounds.size.height * 0.5); 137 | [self.view.layer addSublayer:line3]; 138 | 139 | // load multi with '\n' 140 | CAShapeLayer *line4 = [self multiLinePathStandardLineBreaks]; 141 | line4.position = CGPointMake(self.view.bounds.size.width / 2.0, self.view.bounds.size.height * 0.80); 142 | [self.view.layer addSublayer:line4]; 143 | } 144 | 145 | - (void)didReceiveMemoryWarning 146 | { 147 | [super didReceiveMemoryWarning]; 148 | // Dispose of any resources that can be recreated. 149 | } 150 | 151 | @end 152 | -------------------------------------------------------------------------------- /Text2CGPathDemo/Base.lproj/MainStoryboard.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 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Text2CGPathDemo/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aderussell/string-to-CGPathRef/d744db3e235469b8c97f7a839059b592b3ad6411/Text2CGPathDemo/Default-568h@2x.png -------------------------------------------------------------------------------- /Text2CGPathDemo/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aderussell/string-to-CGPathRef/d744db3e235469b8c97f7a839059b592b3ad6411/Text2CGPathDemo/Default.png -------------------------------------------------------------------------------- /Text2CGPathDemo/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aderussell/string-to-CGPathRef/d744db3e235469b8c97f7a839059b592b3ad6411/Text2CGPathDemo/Default@2x.png -------------------------------------------------------------------------------- /Text2CGPathDemo/SwiftViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftViewController.swift 3 | // Text2CGPathDemo 4 | // 5 | // Created by Adrian Russell on 31/03/2021. 6 | // Copyright © 2021 Adrian Russell. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SwiftViewController: UIViewController { 12 | 13 | let SINGLE_LINE_STRING = "Single line path." 14 | let MULTI_LINE_STRING = "Multi-line string that doesn't have a newline character so is automatically lined to fit width." 15 | let MULTI_LINE_STRING_LINE_BREAKS = "Multi-line string\nwith '\\n' characters\nto\nforce\nnew line." 16 | 17 | let kFonts = [ "Helvetica-Bold", "AmericanTypewriter-CondensedLight", "MarkerFelt-Thin", "TimesNewRomanPS-ItalicMT" ] 18 | let kFontsizes: [CGFloat] = [ 30.0, 60.0, 50.0, 40.0 ] 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | 23 | view.backgroundColor = UIColor(red: 0.78, green: 0.90, blue: 0.91, alpha: 1.0) 24 | } 25 | 26 | override func viewDidAppear(_ animated: Bool) { 27 | super.viewDidAppear(animated) 28 | 29 | // load single with standard string 30 | let line1 = singleLinePathStandard() 31 | line1.position = CGPoint(x: self.view.bounds.size.width / 2.0, 32 | y: self.view.bounds.size.height * 0.10) 33 | view.layer.addSublayer(line1) 34 | 35 | // load single with attributed string 36 | let line2 = singleLinePathAttributed() 37 | line2.position = CGPoint(x: self.view.bounds.size.width / 2.0, 38 | y: self.view.bounds.size.height * 0.25) 39 | view.layer.addSublayer(line2) 40 | 41 | // load multi with attributed string 42 | let line3 = multiLinePathAttributed() 43 | line3.position = CGPoint(x: self.view.bounds.size.width / 2.0, 44 | y: self.view.bounds.size.height * 0.5) 45 | view.layer.addSublayer(line3) 46 | 47 | // load multi with '\n' 48 | let line4 = multiLinePathStandardLineBreaks() 49 | line4.position = CGPoint(x: self.view.bounds.size.width / 2.0, 50 | y: self.view.bounds.size.height * 0.80) 51 | view.layer.addSublayer(line4) 52 | } 53 | 54 | 55 | func attributedString(for string: String) -> NSAttributedString { 56 | let attString = NSMutableAttributedString(string: string) 57 | 58 | for i in 0.. CAShapeLayer { 70 | let font = UIFont.boldSystemFont(ofSize: 60.0) 71 | let line1 = CAShapeLayer() 72 | let path = UIBezierPath(for: SINGLE_LINE_STRING, with: font).cgPath 73 | line1.path = path 74 | line1.bounds = path.boundingBox 75 | line1.isGeometryFlipped = true 76 | line1.fillColor = UIColor.white.cgColor 77 | line1.strokeColor = UIColor.black.cgColor 78 | line1.lineWidth = 1.0 79 | 80 | return line1; 81 | } 82 | 83 | func singleLinePathAttributed() -> CAShapeLayer { 84 | let attString = attributedString(for: SINGLE_LINE_STRING) 85 | let line1 = CAShapeLayer() 86 | let path = UIBezierPath(for: attString).cgPath 87 | line1.path = path 88 | line1.bounds = path.boundingBox 89 | line1.isGeometryFlipped = true 90 | line1.fillColor = UIColor.white.cgColor 91 | line1.strokeColor = UIColor.black.cgColor 92 | line1.lineWidth = 1.0 93 | 94 | return line1 95 | } 96 | 97 | func multiLinePathAttributed() -> CAShapeLayer { 98 | let mutAttr = attributedString(for: MULTI_LINE_STRING).mutableCopy() as! NSMutableAttributedString 99 | 100 | let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle 101 | paragraphStyle.alignment = .justified 102 | 103 | mutAttr.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, mutAttr.length)) 104 | 105 | let line2 = CAShapeLayer() 106 | let path = UIBezierPath(forMultilineAttributedString: mutAttr, 107 | maxWidth: view.bounds.width - 100).cgPath 108 | line2.path = path 109 | line2.bounds = path.boundingBox 110 | line2.isGeometryFlipped = true 111 | line2.fillColor = UIColor.white.cgColor 112 | line2.strokeColor = UIColor.black.cgColor 113 | line2.lineWidth = 1.0 114 | 115 | return line2 116 | } 117 | 118 | func multiLinePathStandardLineBreaks() -> CAShapeLayer { 119 | let line3 = CAShapeLayer() 120 | let path = UIBezierPath(forMultilineString: MULTI_LINE_STRING_LINE_BREAKS, 121 | with: UIFont.boldSystemFont(ofSize: 40.0), 122 | maxWidth: view.bounds.width - 100, 123 | textAlignment: .center).cgPath 124 | line3.path = path 125 | line3.bounds = path.boundingBox 126 | line3.isGeometryFlipped = true 127 | line3.fillColor = UIColor.white.cgColor 128 | line3.strokeColor = UIColor.black.cgColor 129 | line3.lineWidth = 1.0 130 | 131 | return line3 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /Text2CGPathDemo/Text2CGPathDemo-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "UIBezierPath+TextPaths.h" 6 | -------------------------------------------------------------------------------- /Text2CGPathDemo/Text2CGPathDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | MainStoryboard 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations~ipad 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationPortraitUpsideDown 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Text2CGPathDemo/Text2CGPathDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Text2CGPathDemo' target in the 'Text2CGPathDemo' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_5_0 8 | #warning "This project uses features only available in iOS SDK 5.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /Text2CGPathDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Text2CGPathDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Text2CGPathDemo 4 | // 5 | // Created by Adrian Russell on 12/4/12. 6 | // Copyright (c) 2012 Adrian Russell. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "ARAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([ARAppDelegate class])); 17 | } 18 | } 19 | --------------------------------------------------------------------------------