├── Demo ├── Podfile ├── AFSpritz-Demo │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── ViewController.h │ ├── AppDelegate.h │ ├── SpritzViewController.h │ ├── main.m │ ├── AFSpritz-Demo-Prefix.pch │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── AFSpritzWords.h │ ├── NSTimer+Control.h │ ├── AFSpritzLabel.h │ ├── AFSpritz-Demo-Info.plist │ ├── AFSpritzManager.h │ ├── AFSpritzWords.m │ ├── NSTimer+Control.m │ ├── AppDelegate.m │ ├── ViewController.m │ ├── SpritzViewController.m │ ├── AFSpritzManager.m │ ├── AFSpritzLabel.m │ └── Base.lproj │ │ └── Main.storyboard ├── AFSpritz-DemoTests │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── AFSpritz-DemoTests-Info.plist │ └── AFSpritz_DemoTests.m ├── Podfile.lock └── AFSpritz-Demo.xcodeproj │ ├── xcshareddata │ └── xcschemes │ │ └── AFSpritz-Demo.xcscheme │ └── project.pbxproj ├── example.gif ├── .gitignore ├── Classes ├── AFSpritzWords.h ├── NSTimer+Control.h ├── AFSpritzLabel.h ├── AFSpritzManager.h ├── AFSpritzWords.m ├── NSTimer+Control.m ├── AFSpritzManager.m └── AFSpritzLabel.m ├── AFSpritz.podspec ├── LICENSE └── README.md /Demo/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '7.0' 2 | 3 | pod 'AFPopupView', '~> 1.0' -------------------------------------------------------------------------------- /example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlvaroFranco/AFSpritz/HEAD/example.gif -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Demo/AFSpritz-DemoTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Demo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFPopupView (1.0) 3 | 4 | DEPENDENCIES: 5 | - AFPopupView (~> 1.0) 6 | 7 | SPEC CHECKSUMS: 8 | AFPopupView: a3e9e827ed9ce4c7087af259746353aaf7ab75a2 9 | 10 | COCOAPODS: 0.29.0 11 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | # Pods - for those of you who use CocoaPods 20 | Pods -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/SpritzViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SpritzViewController.h 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/18/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SpritzViewController : UIViewController 12 | 13 | @property (nonatomic, strong) NSString *text; 14 | @property (nonatomic) int wpm; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AFSpritz-Demo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/Images.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" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Classes/AFSpritzWords.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzWords.h 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AFSpritzWords : NSObject 12 | 13 | @property (nonatomic, retain, readonly) NSString *word; 14 | @property (nonatomic, assign, readonly) NSUInteger markerPosition; 15 | @property (nonatomic, assign, readonly) NSTimeInterval delay; 16 | 17 | -(instancetype)initWithNextWord:(NSString *)word; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Classes/NSTimer+Control.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSTimer+Blocks.h 3 | // 4 | // Created by Jiva DeVoe on 1/14/11. 5 | // Copyright 2011 Random Ideas, LLC. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface NSTimer (Control) 11 | 12 | +(id)scheduledTimerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats; 13 | +(id)timerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats; 14 | 15 | -(void)pauseTimer; 16 | -(void)resumeTimer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AFSpritzWords.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzWords.h 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AFSpritzWords : NSObject 12 | 13 | @property (nonatomic, retain, readonly) NSString *word; 14 | @property (nonatomic, assign, readonly) NSUInteger markerPosition; 15 | @property (nonatomic, assign, readonly) NSTimeInterval delay; 16 | 17 | -(instancetype)initWithNextWord:(NSString *)word; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/NSTimer+Control.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSTimer+Blocks.h 3 | // 4 | // Created by Jiva DeVoe on 1/14/11. 5 | // Copyright 2011 Random Ideas, LLC. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface NSTimer (Control) 11 | 12 | +(id)scheduledTimerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats; 13 | +(id)timerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats; 14 | 15 | -(void)pauseTimer; 16 | -(void)resumeTimer; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Classes/AFSpritzLabel.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzLabel.h 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AFSpritzWords.h" 11 | 12 | @interface AFSpritzLabel : UIView 13 | 14 | @property (nonatomic, retain) AFSpritzWords *word; 15 | @property (nonatomic, retain) UIColor *markerColor; 16 | @property (nonatomic, retain) UIColor *markingLinesColor; 17 | @property (nonatomic, retain) UIColor *background; 18 | @property (nonatomic, retain) UIColor *textColor; 19 | @property (nonatomic, retain) UIFont *textFont; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AFSpritzLabel.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzLabel.h 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AFSpritzWords.h" 11 | 12 | @interface AFSpritzLabel : UIView 13 | 14 | @property (nonatomic, retain) AFSpritzWords *word; 15 | @property (nonatomic, retain) UIColor *markerColor; 16 | @property (nonatomic, retain) UIColor *markingLinesColor; 17 | @property (nonatomic, retain) UIColor *background; 18 | @property (nonatomic, retain) UIColor *textColor; 19 | @property (nonatomic, retain) UIFont *textFont; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /AFSpritz.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "AFSpritz" 4 | s.version = "1.3.1" 5 | s.summary = "A complete ,ligthweight Spritz SDK for iOS" 6 | 7 | s.description = "AFSpritz is a great SDK for Spritz, a brand new revolutionary reading method" 8 | 9 | s.homepage = "https://github.com/AlvaroFranco/AFSpritz" 10 | 11 | s.license = 'MIT' 12 | s.license = { :type => 'MIT', :file => 'LICENSE' } 13 | 14 | s.author = { "Alvaro Franco" => "alvarofrancoayala@gmail.com" } 15 | 16 | s.platform = :ios 17 | 18 | s.source = { :git => "https://github.com/AlvaroFranco/AFSpritz.git", :tag => 'v1.3.1' } 19 | 20 | s.source_files = 'Classes/' 21 | 22 | s.framework = 'CoreText' 23 | 24 | s.requires_arc = true 25 | 26 | end 27 | -------------------------------------------------------------------------------- /Demo/AFSpritz-DemoTests/AFSpritz-DemoTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.alvarofranco.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Demo/AFSpritz-DemoTests/AFSpritz_DemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritz_DemoTests.m 3 | // AFSpritz-DemoTests 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AFSpritz_DemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation AFSpritz_DemoTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Álvaro Franco 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 | 23 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AFSpritz-Demo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.alvarofranco.${PRODUCT_NAME:rfc1034identifier} 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 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIStatusBarStyle 34 | UIStatusBarStyleLightContent 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UIViewControllerBasedStatusBarAppearance 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Classes/AFSpritzManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzManager.h 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AFSpritzWords.h" 11 | #import "AFSpritzLabel.h" 12 | #import "NSTimer+Control.h" 13 | 14 | typedef NS_ENUM(int, AFSpritzStatus) { 15 | 16 | AFSpritzStatusStopped, 17 | AFSpritzStatusReading, 18 | AFSpritzStatusNotStarted, 19 | AFSpritzStatusFinished 20 | }; 21 | 22 | @interface AFSpritzManager : NSObject 23 | 24 | // statusBlock declaration that returns the current word and the status with the bool finished. 25 | // The update speed depends on the words per minute provided. 26 | typedef void (^statusBlock)(AFSpritzWords *word, BOOL finished); 27 | 28 | // Initialization method 29 | // You need to provide a valid text that will be analized and a number of words per minute, that will regulate the reading speed 30 | -(id)initWithText:(NSString *)text andWordsPerMinute:(int)wpm; 31 | 32 | // Main function 33 | // Is block-driven and the block is called every single time a word changes 34 | // Due is using the statusBlock, returns a AFSpritzWords word and a status bool every time is fired 35 | -(void)updateLabelWithNewWordAndCompletion:(statusBlock)completion; 36 | 37 | // Checks for the Spritz status 38 | -(BOOL)status:(AFSpritzStatus)spritzStatus; 39 | 40 | // Pauses the reading 41 | // It will save the state if the class doesn't get deallocated 42 | -(void)pauseReading; 43 | 44 | // Resumes the reading if it has been previously paused 45 | -(void)resumeReading; 46 | 47 | // Restarts the reading if it has been started 48 | -(void)restartReading; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AFSpritzManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzManager.h 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AFSpritzWords.h" 11 | #import "AFSpritzLabel.h" 12 | #import "NSTimer+Control.h" 13 | 14 | typedef NS_ENUM(int, AFSpritzStatus) { 15 | 16 | AFSpritzStatusStopped, 17 | AFSpritzStatusReading, 18 | AFSpritzStatusNotStarted, 19 | AFSpritzStatusFinished 20 | }; 21 | 22 | @interface AFSpritzManager : NSObject 23 | 24 | // statusBlock declaration that returns the current word and the status with the bool finished. 25 | // The update speed depends on the words per minute provided. 26 | typedef void (^statusBlock)(AFSpritzWords *word, BOOL finished); 27 | 28 | // Initialization method 29 | // You need to provide a valid text that will be analized and a number of words per minute, that will regulate the reading speed 30 | -(id)initWithText:(NSString *)text andWordsPerMinute:(int)wpm; 31 | 32 | // Main function 33 | // Is block-driven and the block is called every single time a word changes 34 | // Due is using the statusBlock, returns a AFSpritzWords word and a status bool every time is fired 35 | -(void)updateLabelWithNewWordAndCompletion:(statusBlock)completion; 36 | 37 | // Checks for the Spritz status 38 | -(BOOL)status:(AFSpritzStatus)spritzStatus; 39 | 40 | // Pauses the reading 41 | // It will save the state if the class doesn't get deallocated 42 | -(void)pauseReading; 43 | 44 | // Resumes the reading if it has been previously paused 45 | -(void)resumeReading; 46 | 47 | // Restarts the reading if it has been started 48 | -(void)restartReading; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Classes/AFSpritzWords.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzWords.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import "AFSpritzWords.h" 10 | 11 | @implementation AFSpritzWords 12 | 13 | -(instancetype)initWithNextWord:(NSString *)word { 14 | 15 | if (self = [super init]) { 16 | 17 | _word = word; 18 | _delay = [self calculateDelay]; 19 | _markerPosition = [self getReaderMarkerPosition]; 20 | } 21 | 22 | return self; 23 | } 24 | 25 | -(NSTimeInterval)calculateDelay { 26 | 27 | NSUInteger length = self.word.length; 28 | static NSTimeInterval minimum = 0.18; 29 | static NSTimeInterval maximum = 0.3; 30 | static NSUInteger minTreshold = 4; 31 | static NSUInteger maxTreshold = 10; 32 | 33 | if (length < minTreshold) { 34 | 35 | return minimum; 36 | } 37 | 38 | if (length > maxTreshold) { 39 | 40 | return maximum; 41 | } 42 | 43 | return minimum + ((maximum - minimum) / (maxTreshold - minTreshold)); 44 | } 45 | 46 | -(NSUInteger)getReaderMarkerPosition { 47 | 48 | NSUInteger length = self.word.length; 49 | NSUInteger letter = 0; 50 | 51 | switch (length) { 52 | 53 | case 1: 54 | case 2: 55 | letter = 0; 56 | break; 57 | 58 | case 3: 59 | case 4: 60 | case 5: 61 | letter = 1; 62 | break; 63 | 64 | case 6: 65 | case 7: 66 | case 8: 67 | case 9: 68 | letter = 2; 69 | break; 70 | 71 | case 10: 72 | case 11: 73 | case 12: 74 | case 13: 75 | letter = 3; 76 | break; 77 | 78 | default: 79 | letter = 4; 80 | } 81 | 82 | return letter; 83 | } 84 | 85 | @end 86 | 87 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AFSpritzWords.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzWords.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import "AFSpritzWords.h" 10 | 11 | @implementation AFSpritzWords 12 | 13 | -(instancetype)initWithNextWord:(NSString *)word { 14 | 15 | if (self = [super init]) { 16 | 17 | _word = word; 18 | _delay = [self calculateDelay]; 19 | _markerPosition = [self getReaderMarkerPosition]; 20 | } 21 | 22 | return self; 23 | } 24 | 25 | -(NSTimeInterval)calculateDelay { 26 | 27 | NSUInteger length = self.word.length; 28 | static NSTimeInterval minimum = 0.18; 29 | static NSTimeInterval maximum = 0.3; 30 | static NSUInteger minTreshold = 4; 31 | static NSUInteger maxTreshold = 10; 32 | 33 | if (length < minTreshold) { 34 | 35 | return minimum; 36 | } 37 | 38 | if (length > maxTreshold) { 39 | 40 | return maximum; 41 | } 42 | 43 | return minimum + ((maximum - minimum) / (maxTreshold - minTreshold)); 44 | } 45 | 46 | -(NSUInteger)getReaderMarkerPosition { 47 | 48 | NSUInteger length = self.word.length; 49 | NSUInteger letter = 0; 50 | 51 | switch (length) { 52 | 53 | case 1: 54 | case 2: 55 | letter = 0; 56 | break; 57 | 58 | case 3: 59 | case 4: 60 | case 5: 61 | letter = 1; 62 | break; 63 | 64 | case 6: 65 | case 7: 66 | case 8: 67 | case 9: 68 | letter = 2; 69 | break; 70 | 71 | case 10: 72 | case 11: 73 | case 12: 74 | case 13: 75 | letter = 3; 76 | break; 77 | 78 | default: 79 | letter = 4; 80 | } 81 | 82 | return letter; 83 | } 84 | 85 | @end 86 | 87 | -------------------------------------------------------------------------------- /Classes/NSTimer+Control.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSTimer+Blocks.m 3 | // 4 | // Created by Jiva DeVoe on 1/14/11. 5 | // Copyright 2011 Random Ideas, LLC. All rights reserved. 6 | // 7 | 8 | #import "NSTimer+Control.h" 9 | #import 10 | 11 | @implementation NSTimer (Control) 12 | 13 | +(id)scheduledTimerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats { 14 | 15 | void (^block)() = [inBlock copy]; 16 | id ret = [self scheduledTimerWithTimeInterval:inTimeInterval target:self selector:@selector(jdExecuteSimpleBlock:) userInfo:block repeats:inRepeats]; 17 | 18 | return ret; 19 | } 20 | 21 | +(id)timerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats { 22 | 23 | void (^block)() = [inBlock copy]; 24 | id ret = [self timerWithTimeInterval:inTimeInterval target:self selector:@selector(jdExecuteSimpleBlock:) userInfo:block repeats:inRepeats]; 25 | 26 | return ret; 27 | } 28 | 29 | +(void)jdExecuteSimpleBlock:(NSTimer *)inTimer { 30 | 31 | if([inTimer userInfo]) { 32 | void (^block)() = (void (^)())[inTimer userInfo]; 33 | block(); 34 | } 35 | } 36 | 37 | static NSString *const NSTimerPauseDate = @"NSTimerPauseDate"; 38 | static NSString *const NSTimerPreviousFireDate = @"NSTimerPreviousFireDate"; 39 | 40 | -(void)pauseTimer { 41 | 42 | objc_setAssociatedObject(self, (__bridge const void *)(NSTimerPauseDate), [NSDate date], OBJC_ASSOCIATION_RETAIN_NONATOMIC); 43 | objc_setAssociatedObject(self, (__bridge const void *)(NSTimerPreviousFireDate), self.fireDate, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | 45 | self.fireDate = [NSDate distantFuture]; 46 | } 47 | 48 | -(void)resumeTimer { 49 | 50 | NSDate *pauseDate = objc_getAssociatedObject(self, (__bridge const void *)NSTimerPauseDate); 51 | NSDate *previousFireDate = objc_getAssociatedObject(self, (__bridge const void *)NSTimerPreviousFireDate); 52 | 53 | const NSTimeInterval pauseTime = -[pauseDate timeIntervalSinceNow]; 54 | self.fireDate = [NSDate dateWithTimeInterval:pauseTime sinceDate:previousFireDate]; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/NSTimer+Control.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSTimer+Blocks.m 3 | // 4 | // Created by Jiva DeVoe on 1/14/11. 5 | // Copyright 2011 Random Ideas, LLC. All rights reserved. 6 | // 7 | 8 | #import "NSTimer+Control.h" 9 | #import 10 | 11 | @implementation NSTimer (Control) 12 | 13 | +(id)scheduledTimerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats { 14 | 15 | void (^block)() = [inBlock copy]; 16 | id ret = [self scheduledTimerWithTimeInterval:inTimeInterval target:self selector:@selector(jdExecuteSimpleBlock:) userInfo:block repeats:inRepeats]; 17 | 18 | return ret; 19 | } 20 | 21 | +(id)timerWithTimeInterval:(NSTimeInterval)inTimeInterval block:(void (^)())inBlock repeats:(BOOL)inRepeats { 22 | 23 | void (^block)() = [inBlock copy]; 24 | id ret = [self timerWithTimeInterval:inTimeInterval target:self selector:@selector(jdExecuteSimpleBlock:) userInfo:block repeats:inRepeats]; 25 | 26 | return ret; 27 | } 28 | 29 | +(void)jdExecuteSimpleBlock:(NSTimer *)inTimer { 30 | 31 | if([inTimer userInfo]) { 32 | void (^block)() = (void (^)())[inTimer userInfo]; 33 | block(); 34 | } 35 | } 36 | 37 | static NSString *const NSTimerPauseDate = @"NSTimerPauseDate"; 38 | static NSString *const NSTimerPreviousFireDate = @"NSTimerPreviousFireDate"; 39 | 40 | -(void)pauseTimer { 41 | 42 | objc_setAssociatedObject(self, (__bridge const void *)(NSTimerPauseDate), [NSDate date], OBJC_ASSOCIATION_RETAIN_NONATOMIC); 43 | objc_setAssociatedObject(self, (__bridge const void *)(NSTimerPreviousFireDate), self.fireDate, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | 45 | self.fireDate = [NSDate distantFuture]; 46 | } 47 | 48 | -(void)resumeTimer { 49 | 50 | NSDate *pauseDate = objc_getAssociatedObject(self, (__bridge const void *)NSTimerPauseDate); 51 | NSDate *previousFireDate = objc_getAssociatedObject(self, (__bridge const void *)NSTimerPreviousFireDate); 52 | 53 | const NSTimeInterval pauseTime = -[pauseDate timeIntervalSinceNow]; 54 | self.fireDate = [NSDate dateWithTimeInterval:pauseTime sinceDate:previousFireDate]; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 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 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SpritzViewController.h" 11 | #import "AFPopupView.h" 12 | 13 | @interface ViewController () 14 | 15 | @property (nonatomic, strong) IBOutlet UITextView *textView; 16 | @property (nonatomic, strong) IBOutlet UIButton *showSpritzButton; 17 | @property (nonatomic, strong) IBOutlet UISwitch *customSpeed; 18 | @property (nonatomic, strong) IBOutlet UISlider *wpmSlider; 19 | @property (nonatomic, strong) IBOutlet UILabel *wpmLabel; 20 | 21 | @property (nonatomic, strong) AFPopupView *popup; 22 | @property (nonatomic, strong) SpritzViewController *spritzVC; 23 | 24 | @end 25 | 26 | @implementation ViewController 27 | 28 | -(UIStatusBarStyle)preferredStatusBarStyle { 29 | 30 | return UIStatusBarStyleLightContent; 31 | } 32 | 33 | -(void)viewWillAppear:(BOOL)animated { 34 | [super viewWillAppear:animated]; 35 | 36 | UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:Nil]; 37 | _spritzVC = [storyboard instantiateViewControllerWithIdentifier:@"SpritzVC"]; 38 | 39 | _wpmSlider.value = 0.25; 40 | [_wpmSlider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged]; 41 | 42 | _wpmLabel.text = [NSString stringWithFormat:@"%0.f words per minute", (_wpmSlider.value * 600) + 100]; 43 | 44 | [_customSpeed addTarget:self action:@selector(switcherChanged) forControlEvents:UIControlEventValueChanged]; 45 | 46 | [_showSpritzButton addTarget:self action:@selector(show) forControlEvents:UIControlEventTouchUpInside]; 47 | 48 | [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(hide) name:@"HideSpritzPopup" object:nil]; 49 | } 50 | 51 | -(void)show { 52 | 53 | if ([_customSpeed isOn]) { 54 | _spritzVC.wpm = ceilf((_wpmSlider.value * 600) + 100); 55 | } 56 | _spritzVC.text = _textView.text; 57 | _popup = [AFPopupView popupWithView:_spritzVC.view]; 58 | [_popup show]; 59 | } 60 | 61 | -(void)hide { 62 | 63 | [_popup hide]; 64 | } 65 | 66 | -(void)switcherChanged { 67 | 68 | if ([_customSpeed isOn]) { 69 | _wpmSlider.enabled = YES; 70 | } else { 71 | _wpmSlider.enabled = NO; 72 | } 73 | } 74 | 75 | -(void)sliderChanged:(UISlider *)sender { 76 | 77 | _wpmLabel.text = [NSString stringWithFormat:@"%0.f words per minute", (sender.value * 600) + 100]; 78 | } 79 | 80 | -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 81 | 82 | [_textView resignFirstResponder]; 83 | } 84 | 85 | -(void)viewWillDisappear:(BOOL)animated { 86 | [super viewWillDisappear:animated]; 87 | } 88 | 89 | -(void)didReceiveMemoryWarning { 90 | [super didReceiveMemoryWarning]; 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/SpritzViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SpritzViewController.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/18/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import "SpritzViewController.h" 10 | #import "AFSpritzManager.h" 11 | 12 | @interface SpritzViewController () 13 | 14 | @property (nonatomic, strong) IBOutlet UIButton *startButton; 15 | @property (nonatomic, strong) IBOutlet UIButton *pauseButton; 16 | @property (nonatomic, strong) IBOutlet UIButton *resumeButton; 17 | @property (nonatomic, strong) IBOutlet UIButton *restartButton; 18 | @property (nonatomic, strong) IBOutlet UIButton *closeButton; 19 | 20 | @property (nonatomic, strong) AFSpritzManager *manager; 21 | 22 | @end 23 | 24 | @implementation SpritzViewController 25 | 26 | -(void)viewWillAppear:(BOOL)animated { 27 | [super viewWillAppear:animated]; 28 | 29 | AFSpritzLabel *spritzLabel = [[AFSpritzLabel alloc] initWithFrame:CGRectMake(20, 20, 200, 40)]; 30 | spritzLabel.center = CGPointMake([[UIScreen mainScreen] bounds].size.width / 2, 100); 31 | [self.view addSubview:spritzLabel]; 32 | 33 | self.view.backgroundColor = [UIColor clearColor]; 34 | UIToolbar *blurBar = [[UIToolbar alloc] initWithFrame:self.view.frame]; 35 | blurBar.barStyle = UIBarStyleDefault; 36 | [self.view addSubview:blurBar]; 37 | [self.view sendSubviewToBack:blurBar]; 38 | 39 | [_startButton addTarget:self action:@selector(toggleSpritz) forControlEvents:UIControlEventTouchUpInside]; 40 | [_closeButton addTarget:self action:@selector(closePopup) forControlEvents:UIControlEventTouchUpInside]; 41 | } 42 | 43 | -(void)closePopup { 44 | 45 | [[NSNotificationCenter defaultCenter] postNotificationName:@"HideSpritzPopup" object:nil]; 46 | } 47 | 48 | -(void)toggleSpritz { 49 | 50 | _manager = [[AFSpritzManager alloc]initWithText:_text andWordsPerMinute:_wpm ? _wpm : 250]; 51 | 52 | [_manager updateLabelWithNewWordAndCompletion:^(AFSpritzWords *word, BOOL finished) { 53 | 54 | if (!finished) { 55 | 56 | AFSpritzLabel *spritzLabel = [[AFSpritzLabel alloc]initWithFrame:CGRectMake(20, 20, 200, 40)]; 57 | spritzLabel.center = CGPointMake([[UIScreen mainScreen]bounds].size.width / 2, 100); 58 | spritzLabel.word = word; 59 | [self.view addSubview:spritzLabel]; 60 | } else { 61 | NSLog(@"Finished!"); 62 | } 63 | }]; 64 | 65 | [_pauseButton addTarget:_manager action:@selector(pauseReading) forControlEvents:UIControlEventTouchUpInside]; 66 | [_resumeButton addTarget:_manager action:@selector(resumeReading) forControlEvents:UIControlEventTouchUpInside]; 67 | [_restartButton addTarget:_manager action:@selector(restartReading) forControlEvents:UIControlEventTouchUpInside]; 68 | } 69 | 70 | -(void)didReceiveMemoryWarning { 71 | [super didReceiveMemoryWarning]; 72 | // Dispose of any resources that can be recreated. 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo.xcodeproj/xcshareddata/xcschemes/AFSpritz-Demo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 63 | 69 | 70 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AFSpritz 2 | ======================= 3 | 4 | [![Build Status](https://travis-ci.org/AlvaroFranco/AFSpritz.svg?branch=master)](https://travis-ci.org/AlvaroFranco/AFSpritz) 5 | [![alt text](https://cocoapod-badges.herokuapp.com/v/AFSpritz/badge.png)]() 6 | [![alt text](https://cocoapod-badges.herokuapp.com/p/AFSpritz/badge.png)]() 7 | [![alt text](https://camo.githubusercontent.com/f513623dcee61532125032bbf1ddffda06ba17c7/68747470733a2f2f676f2d736869656c64732e6865726f6b756170702e636f6d2f6c6963656e73652d4d49542d626c75652e706e67)]() 8 | 9 | A complete, lightweight Spritz SDK for iOS 10 | 11 | ![alt text](https://raw.github.com/AlvaroFranco/AFSpritz/master/example.gif "Example") 12 | 13 | ##CocoaPods 14 | 15 | AFSpritz is on [CocoaPods](http://cocoapods.org), so you can get the pod by adding this line to your Podfile 16 | 17 | pod 'AFSpritz', '~> 1.3.1' 18 | 19 | If not, just import these files to your project: 20 | 21 | AFSpritzManager.h 22 | AFSpritzManager.m 23 | AFSpritzWords.h 24 | AFSpritzWords.m 25 | AFSpritzLabel.h 26 | AFSpritzLabel.m 27 | NSTimer+Control.h 28 | NSTimer+Control.m 29 | 30 | ##Usage 31 | 32 | First of all, import AFSpritzManager.h to your class 33 | 34 | ```objc 35 | #import "AFSpritzManager.h" 36 | ``` 37 | 38 | Initialise ```AFSpritzManager``` assigning a text and a number of words per minute, that will determine the speed of the reading. Theorically, there's no limit, but the more confortable speed is 200-250 words per minute. However, Spritz is made for let you read more than 500 words per minute. 39 | 40 | ```objc 41 | AFSpritzManager *manager = [[AFSpritzManager alloc] initWithText:@"Welcome to AFSpritz! Spritz is a brand new revolutionary reading method that will help you to improve your number of words per minute. Take a look at AFSpritz!" andWordsPerMinute:250]; 42 | ``` 43 | 44 | Then, call the block that will update the Spritz label 45 | 46 | ```objc 47 | [manager updateLabelWithNewWordAndCompletion:^(AFSpritzWords *word, BOOL finished) { 48 | 49 | if (!finished) { 50 | 51 | //Update the AFSpritzLabel 52 | } else { 53 | NSLog(@"Finished!"); 54 | } 55 | }]; 56 | ``` 57 | 58 | ###Checking the status 59 | 60 | ```objc 61 | typedef NS_ENUM(int, AFSpritzStatus) { 62 | 63 | AFSpritzStatusStopped, 64 | AFSpritzStatusReading, 65 | AFSpritzStatusNotStarted, 66 | AFSpritzStatusFinished 67 | }; 68 | ``` 69 | 70 | AFSpritz has the feature of checking in each moment the status of the reading using ```-status:```. 71 | 72 | Example: 73 | 74 | ```objc 75 | if ([manager status:AFSpritzStatusReading]) { 76 | 77 | // The current status is reading 78 | } else if ([manager status:AFSpritzStatusNotStarted]) { 79 | 80 | // The current status is not started yet 81 | } else if ([manager status:AFSpritzStatusStopped]) { 82 | 83 | // The current status is stopped, so it can be resumed 84 | } else if ([manager status:AFSpritzStatusFinished]) { 85 | 86 | // The current status is finished 87 | } 88 | ``` 89 | 90 | ###Pausing, resuming and restarting 91 | 92 | Now you can pause, resume and restart your reading just calling these three methods: 93 | 94 | ```objc 95 | [manager pauseReading]; 96 | 97 | [manager resumeReading]; 98 | 99 | [manager restartReading]; 100 | ``` 101 | 102 | ##AFSpritzLabel API 103 | 104 | AFSpritzLabel is an incredible, well crafted and 100% AFSpritzWords-compatible UIView subclass that will let you show your Spritz reading. 105 | 106 | You can customize many properties from AFSpritzLabel, such as: 107 | 108 | | Property | Class | Required | Default | Description | 109 | |----------|-------|----------|---------|-------------| 110 | | word | AFSpritzWords | Yes | nil | Determines the AFSpritzWords-subclassed word to show. | 111 | | markerColor | UIColor | No | Red | Determines the color of the letter you're supposed to be focused on. | 112 | | markeringLinesColor | UIColor | No | Black | Determines the color of the lines around the word. | 113 | | textColor | UIColor | No | Black | Determines the color of the text. | 114 | | textFont | UIFont | No | System font with size 20 | Determines the font of the text. | 115 | | backgroundColor | UIColor | No | White | Determines the color of the background. | 116 | 117 | ##Wishlist 118 | 119 | - [x] Customize speed throught the number of words per minute. 120 | 121 | - [x] Stop and resume the reading. 122 | 123 | - [x] Add a little stop when there's a stop on the text (. … : , ! ?). 124 | 125 | - [x] Restart the reading. (Thanks [Ayberk](https://github.com/ayberkt)!) 126 | 127 | - [ ] Different speed based on the word length. 128 | 129 | ##Author 130 | 131 | Made by Alvaro Franco. If you have any question, feel free to drop me a line at [alvarofrancoayala@gmail.com](mailto:alvarofrancoayala@gmail.com) -------------------------------------------------------------------------------- /Classes/AFSpritzManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzManager.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import "AFSpritzManager.h" 10 | 11 | @interface AFSpritzManager () 12 | 13 | @property (nonatomic, strong) NSString *text; 14 | 15 | @property (nonatomic, strong) NSArray *words; 16 | @property (nonatomic) NSUInteger current; 17 | @property (nonatomic) float speed; 18 | @property (nonatomic) NSTimer *timer; 19 | 20 | @property (nonatomic) int status; 21 | 22 | -(NSMutableArray *)packageOfWords; 23 | -(BOOL)containsFullStop:(NSString *)wordToAnalyze; 24 | 25 | @end 26 | 27 | @implementation AFSpritzManager 28 | 29 | -(id)initWithText:(NSString *)text andWordsPerMinute:(int)wpm { 30 | 31 | self = [super init]; 32 | 33 | if (self) { 34 | 35 | if (!wpm) { 36 | 37 | wpm = 250; 38 | NSLog(@"AFSpritz message: You need to provide a valid number of words per minute. If not, 250 words per minute will be used by default"); 39 | } 40 | 41 | _status = AFSpritzStatusNotStarted; 42 | 43 | _text = text; 44 | _speed = (wpm / 60); 45 | _speed = (1/_speed); 46 | 47 | NSArray *wordsSeparated = [self.text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 48 | 49 | NSMutableArray *fixedArray = [NSMutableArray array]; 50 | 51 | for (NSString *singleWord in wordsSeparated) { 52 | 53 | [fixedArray addObject:[singleWord stringByAppendingString:@" "]]; 54 | } 55 | 56 | if (fixedArray.count) { 57 | 58 | _current = 0; 59 | _words = fixedArray; 60 | } 61 | } 62 | 63 | return self; 64 | } 65 | 66 | -(void)updateLabelWithNewWordAndCompletion:(statusBlock)completion { 67 | 68 | NSMutableArray *wordsArray = [self packageOfWords]; 69 | 70 | _timer = [NSTimer scheduledTimerWithTimeInterval:_speed block:^{ 71 | 72 | if (_current != wordsArray.count) { 73 | 74 | if (_current > 0) { 75 | 76 | if ([self containsFullStop:[(AFSpritzWords *)wordsArray[_current - 1]word]]) { 77 | 78 | clock_t end = clock() + (_speed * CLOCKS_PER_SEC); 79 | while (clock() < end); 80 | } 81 | } 82 | 83 | _status = AFSpritzStatusReading; 84 | 85 | if (completion) { 86 | 87 | completion([wordsArray objectAtIndex:_current], NO); 88 | } 89 | 90 | _current++; 91 | } else if (_current == wordsArray.count) { 92 | 93 | if (completion) { 94 | 95 | completion(nil, YES); 96 | } 97 | 98 | [_timer invalidate]; 99 | _status = AFSpritzStatusFinished; 100 | } 101 | 102 | } repeats:YES]; 103 | } 104 | 105 | -(BOOL)containsFullStop:(NSString *)wordToAnalyze { 106 | 107 | if ([wordToAnalyze rangeOfString:@". "].location != NSNotFound) { 108 | return YES; 109 | } else if ([wordToAnalyze rangeOfString:@"! "].location != NSNotFound) { 110 | return YES; 111 | } else if ([wordToAnalyze rangeOfString:@", "].location != NSNotFound) { 112 | return YES; 113 | } else if ([wordToAnalyze rangeOfString:@"... "].location != NSNotFound) { 114 | return YES; 115 | } else if ([wordToAnalyze rangeOfString:@"… "].location != NSNotFound) { 116 | return YES; 117 | } else if ([wordToAnalyze rangeOfString:@"? "].location != NSNotFound) { 118 | return YES; 119 | } else if ([wordToAnalyze rangeOfString:@": "].location != NSNotFound) { 120 | return YES; 121 | } else if ([wordToAnalyze rangeOfString:@"; "].location != NSNotFound) { 122 | return YES; 123 | } 124 | 125 | return NO; 126 | } 127 | 128 | -(NSMutableArray *)packageOfWords { 129 | 130 | NSMutableArray *tempArray = [NSMutableArray array]; 131 | 132 | for (NSString *word in _words) { 133 | 134 | [tempArray addObject:[[AFSpritzWords alloc] initWithNextWord:word]]; 135 | } 136 | 137 | return tempArray; 138 | } 139 | 140 | -(void)resumeReading { 141 | 142 | if ([self status:AFSpritzStatusStopped]) { 143 | 144 | _status = AFSpritzStatusReading; 145 | [_timer resumeTimer]; 146 | } else { 147 | 148 | NSLog(@"AFSpritz message: Reading can only be resumed when is stopped"); 149 | } 150 | } 151 | 152 | -(void)pauseReading { 153 | 154 | if ([self status:AFSpritzStatusReading]) { 155 | 156 | _status = AFSpritzStatusStopped; 157 | [_timer pauseTimer]; 158 | } else { 159 | 160 | NSLog(@"AFSpritz message: Reading can only be paused when the reading is active"); 161 | } 162 | } 163 | 164 | -(void)restartReading { 165 | 166 | if ([self status:AFSpritzStatusReading]) { 167 | 168 | _current = 0; 169 | } else { 170 | 171 | NSLog(@"AFSpritz message: Reading can only be restarted when the reading is active"); 172 | } 173 | } 174 | 175 | -(BOOL)status:(AFSpritzStatus)spritzStatus { 176 | 177 | if (spritzStatus == _status) { 178 | 179 | return YES; 180 | } else { 181 | 182 | return NO; 183 | } 184 | } 185 | 186 | @end 187 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AFSpritzManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzManager.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import "AFSpritzManager.h" 10 | 11 | @interface AFSpritzManager () 12 | 13 | @property (nonatomic, strong) NSString *text; 14 | 15 | @property (nonatomic, strong) NSArray *words; 16 | @property (nonatomic) NSUInteger current; 17 | @property (nonatomic) float speed; 18 | @property (nonatomic) NSTimer *timer; 19 | 20 | @property (nonatomic) int status; 21 | 22 | -(NSMutableArray *)packageOfWords; 23 | -(BOOL)containsFullStop:(NSString *)wordToAnalyze; 24 | 25 | @end 26 | 27 | @implementation AFSpritzManager 28 | 29 | -(id)initWithText:(NSString *)text andWordsPerMinute:(int)wpm { 30 | 31 | self = [super init]; 32 | 33 | if (self) { 34 | 35 | if (!wpm) { 36 | 37 | wpm = 250; 38 | NSLog(@"AFSpritz message: You need to provide a valid number of words per minute. If not, 250 words per minute will be used by default"); 39 | } 40 | 41 | _status = AFSpritzStatusNotStarted; 42 | 43 | _text = text; 44 | _speed = (wpm / 60); 45 | _speed = (1/_speed); 46 | 47 | NSArray *wordsSeparated = [self.text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 48 | 49 | NSMutableArray *fixedArray = [NSMutableArray array]; 50 | 51 | for (NSString *singleWord in wordsSeparated) { 52 | 53 | [fixedArray addObject:[singleWord stringByAppendingString:@" "]]; 54 | } 55 | 56 | if (fixedArray.count) { 57 | 58 | _current = 0; 59 | _words = fixedArray; 60 | } 61 | } 62 | 63 | return self; 64 | } 65 | 66 | -(void)updateLabelWithNewWordAndCompletion:(statusBlock)completion { 67 | 68 | NSMutableArray *wordsArray = [self packageOfWords]; 69 | 70 | _timer = [NSTimer scheduledTimerWithTimeInterval:_speed block:^{ 71 | 72 | if (_current != wordsArray.count) { 73 | 74 | if (_current > 0) { 75 | 76 | if ([self containsFullStop:[(AFSpritzWords *)wordsArray[_current - 1]word]]) { 77 | 78 | clock_t end = clock() + (_speed * CLOCKS_PER_SEC); 79 | while (clock() < end); 80 | } 81 | } 82 | 83 | _status = AFSpritzStatusReading; 84 | 85 | if (completion) { 86 | 87 | completion([wordsArray objectAtIndex:_current], NO); 88 | } 89 | 90 | _current++; 91 | } else if (_current == wordsArray.count) { 92 | 93 | if (completion) { 94 | 95 | completion(nil, YES); 96 | } 97 | 98 | [_timer invalidate]; 99 | _status = AFSpritzStatusFinished; 100 | } 101 | 102 | } repeats:YES]; 103 | } 104 | 105 | -(BOOL)containsFullStop:(NSString *)wordToAnalyze { 106 | 107 | if ([wordToAnalyze rangeOfString:@". "].location != NSNotFound) { 108 | return YES; 109 | } else if ([wordToAnalyze rangeOfString:@"! "].location != NSNotFound) { 110 | return YES; 111 | } else if ([wordToAnalyze rangeOfString:@", "].location != NSNotFound) { 112 | return YES; 113 | } else if ([wordToAnalyze rangeOfString:@"... "].location != NSNotFound) { 114 | return YES; 115 | } else if ([wordToAnalyze rangeOfString:@"… "].location != NSNotFound) { 116 | return YES; 117 | } else if ([wordToAnalyze rangeOfString:@"? "].location != NSNotFound) { 118 | return YES; 119 | } else if ([wordToAnalyze rangeOfString:@": "].location != NSNotFound) { 120 | return YES; 121 | } else if ([wordToAnalyze rangeOfString:@"; "].location != NSNotFound) { 122 | return YES; 123 | } 124 | 125 | return NO; 126 | } 127 | 128 | -(NSMutableArray *)packageOfWords { 129 | 130 | NSMutableArray *tempArray = [NSMutableArray array]; 131 | 132 | for (NSString *word in _words) { 133 | 134 | [tempArray addObject:[[AFSpritzWords alloc] initWithNextWord:word]]; 135 | } 136 | 137 | return tempArray; 138 | } 139 | 140 | -(void)resumeReading { 141 | 142 | if ([self status:AFSpritzStatusStopped]) { 143 | 144 | _status = AFSpritzStatusReading; 145 | [_timer resumeTimer]; 146 | } else { 147 | 148 | NSLog(@"AFSpritz message: Reading can only be resumed when is stopped"); 149 | } 150 | } 151 | 152 | -(void)pauseReading { 153 | 154 | if ([self status:AFSpritzStatusReading]) { 155 | 156 | _status = AFSpritzStatusStopped; 157 | [_timer pauseTimer]; 158 | } else { 159 | 160 | NSLog(@"AFSpritz message: Reading can only be paused when the reading is active"); 161 | } 162 | } 163 | 164 | -(void)restartReading { 165 | 166 | if ([self status:AFSpritzStatusReading]) { 167 | 168 | _current = 0; 169 | } else { 170 | 171 | NSLog(@"AFSpritz message: Reading can only be restarted when the reading is active"); 172 | } 173 | } 174 | 175 | -(BOOL)status:(AFSpritzStatus)spritzStatus { 176 | 177 | if (spritzStatus == _status) { 178 | 179 | return YES; 180 | } else { 181 | 182 | return NO; 183 | } 184 | } 185 | 186 | @end 187 | -------------------------------------------------------------------------------- /Classes/AFSpritzLabel.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzLabel.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import "AFSpritzLabel.h" 10 | #import "AFSpritzWords.h" 11 | #import 12 | 13 | typedef enum { 14 | 15 | AFSpritzLabelTextPartHeader, 16 | AFSpritzLabelTextPartMarker, 17 | AFSpritzLabelTextPartTail 18 | } AFSpritzLabelTextPart; 19 | 20 | @implementation AFSpritzLabel { 21 | 22 | CGFloat markerOffset; 23 | CGFloat markerLength; 24 | 25 | CGFloat headerWidth; 26 | CGFloat tailWidth; 27 | CGFloat markerWidth; 28 | 29 | CGFloat textVerticalPosition; 30 | CGFloat textHorizontalPosition; 31 | } 32 | 33 | -(id)initWithFrame:(CGRect)frame { 34 | 35 | if (self == [super initWithFrame:frame]) { 36 | 37 | [self defaultParameters]; 38 | } 39 | 40 | return self; 41 | } 42 | 43 | -(id)initWithCoder:(NSCoder *)aDecoder { 44 | 45 | if (self == [super initWithCoder:aDecoder]) { 46 | 47 | [self defaultParameters]; 48 | } 49 | 50 | return self; 51 | } 52 | 53 | -(void)defaultParameters { 54 | 55 | markerOffset = self.frame.size.width / 3; 56 | markerLength = 5; 57 | textVerticalPosition = 15; 58 | _markerColor = [UIColor redColor]; 59 | _markingLinesColor = [UIColor blackColor]; 60 | _background = [UIColor whiteColor]; 61 | _textColor = [UIColor blackColor]; 62 | _textFont = [UIFont systemFontOfSize:20]; 63 | _word = [[AFSpritzWords alloc] initWithNextWord:@" "]; 64 | 65 | self.layer.cornerRadius = 10; 66 | self.layer.masksToBounds = YES; 67 | self.backgroundColor = _background; 68 | } 69 | 70 | -(void)setWord:(AFSpritzWords *)word { 71 | 72 | if (_word != word) { 73 | 74 | _word = word; 75 | 76 | [self setNeedsDisplay]; 77 | } 78 | } 79 | 80 | -(void)drawRect:(CGRect)rect { 81 | 82 | [super drawRect:rect]; 83 | CGContextRef context = UIGraphicsGetCurrentContext(); 84 | 85 | [self drawMarkingLinesWithOffset:markerOffset andLength:markerLength]; 86 | 87 | [self flipCoordinateSystemForCoreText]; 88 | 89 | CGMutablePathRef path = CGPathCreateMutable(); 90 | CGPathAddRect(path, NULL, self.bounds ); 91 | 92 | NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:self.word.word]; 93 | 94 | [attString addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(self.word.markerPosition, 1)]; 95 | [attString addAttribute:NSFontAttributeName value:self.textFont range:NSMakeRange(0, self.word.word.length)]; 96 | 97 | CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attString); 98 | CTFrameRef frame = CTFramesetterCreateFrame(framesetter,CFRangeMake(0, [attString length]), path, NULL); 99 | 100 | NSArray *lines = (NSArray *)CTFrameGetLines(frame); 101 | 102 | for (id lineObj in lines) { 103 | 104 | CTLineRef line = (__bridge CTLineRef)lineObj; 105 | NSArray *runs = (NSArray *)CTLineGetGlyphRuns(line); 106 | 107 | for (CFIndex runIndex = 0; runIndex < runs.count; ++runIndex) { 108 | 109 | CTRunRef run = (__bridge CTRunRef)[runs objectAtIndex:runIndex]; 110 | CGFloat width = 0; 111 | width = (CGFloat)CTRunGetTypographicBounds(run, CFRangeMake(0, 0), NULL, NULL, NULL); 112 | 113 | switch (runIndex) { 114 | 115 | case AFSpritzLabelTextPartHeader: 116 | headerWidth = width; 117 | 118 | if (runs.count == 1) { 119 | 120 | headerWidth = 0; 121 | markerWidth = width; 122 | [self recomputeTextHorizontalPosition]; 123 | } 124 | 125 | break; 126 | 127 | case AFSpritzLabelTextPartMarker: 128 | markerWidth = width; 129 | 130 | if (runs.count == 2) { 131 | 132 | if (self.word.markerPosition) { 133 | 134 | } else { 135 | 136 | markerWidth = headerWidth; 137 | headerWidth = 0; 138 | markerWidth = width; 139 | } 140 | 141 | [self recomputeTextHorizontalPosition]; 142 | } 143 | 144 | break; 145 | 146 | case AFSpritzLabelTextPartTail: 147 | tailWidth = width; 148 | [self recomputeTextHorizontalPosition]; 149 | break; 150 | 151 | default: 152 | break; 153 | } 154 | } 155 | 156 | for (CFIndex runIndex = 0; runIndex < runs.count; ++runIndex) { 157 | 158 | CTRunRef run = (__bridge CTRunRef)[runs objectAtIndex:runIndex]; 159 | CTFontRef runFont = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName); 160 | 161 | for (CFIndex runGlyphIndex = 0 ; runGlyphIndex < CTRunGetGlyphCount(run) ; runGlyphIndex++) { 162 | 163 | CFRange thisGlyphRange = CFRangeMake(runGlyphIndex, 1); 164 | CGGlyph glyph; 165 | CGPoint position; 166 | CTRunGetGlyphs(run, thisGlyphRange, &glyph); 167 | CTRunGetPositions(run, thisGlyphRange, &position); 168 | 169 | if ((runs.count >= 3 && runIndex == AFSpritzLabelTextPartMarker) || 170 | (runs.count == 1 && !self.word.markerPosition) || 171 | (runs.count == 2 && self.word.markerPosition && runIndex) || 172 | (runs.count == 2 && !self.word.markerPosition && !runIndex)) { 173 | 174 | CGContextSetFillColorWithColor(context, self.markerColor.CGColor); 175 | } else { 176 | 177 | CGContextSetFillColorWithColor(context, self.textColor.CGColor); 178 | } 179 | 180 | position = CGPointMake(position.x + textHorizontalPosition, position.y + textVerticalPosition); 181 | 182 | { 183 | CGFontRef cgFont = CTFontCopyGraphicsFont(runFont, NULL); 184 | 185 | CGAffineTransform textMatrix = CTRunGetTextMatrix(run); 186 | CGContextSetTextMatrix(context, textMatrix); 187 | CGContextSetFont(context, cgFont); 188 | CGContextSetFontSize(context, CTFontGetSize(runFont)); 189 | 190 | CGContextShowGlyphsAtPositions(context, &glyph, &position, 1); 191 | 192 | CFRelease(cgFont); 193 | } 194 | } 195 | } 196 | } 197 | 198 | CFRelease(frame); 199 | CFRelease(path); 200 | CFRelease(framesetter); 201 | } 202 | 203 | -(void)recomputeTextHorizontalPosition { 204 | 205 | textHorizontalPosition = markerOffset - (headerWidth + markerWidth/2.0f); 206 | } 207 | 208 | -(void)drawLineInContextWithWidth:(CGFloat)width fromPointX:(CGFloat)fx fromY:(CGFloat)fy toX:(CGFloat)tx toY:(CGFloat)ty { 209 | 210 | CGContextRef context = UIGraphicsGetCurrentContext(); 211 | CGContextSetLineWidth(context, width); 212 | 213 | CGContextMoveToPoint(context, fx, fy); 214 | CGContextAddLineToPoint(context, tx, ty); 215 | 216 | CGContextStrokePath(context); 217 | } 218 | 219 | -(void)drawMarkingLinesWithOffset:(CGFloat)offset andLength:(CGFloat)length { 220 | 221 | CGFloat verticalOffset = 4.0f; 222 | CGFloat horizontalOffset = 10.0f; 223 | 224 | [self.markingLinesColor set]; 225 | [self drawLineInContextWithWidth:1.0f fromPointX:offset fromY:self.frame.size.height-length - verticalOffset toX:offset toY:self.frame.size.height - verticalOffset]; 226 | [self drawLineInContextWithWidth:1.0f fromPointX:offset fromY:verticalOffset toX:offset toY:length + verticalOffset]; 227 | 228 | [self drawLineInContextWithWidth:2.0f fromPointX:horizontalOffset fromY:verticalOffset toX:self.frame.size.width - horizontalOffset toY:verticalOffset]; 229 | [self drawLineInContextWithWidth:2.0f fromPointX:horizontalOffset fromY:self.frame.size.height-verticalOffset toX:self.frame.size.width - horizontalOffset toY:self.frame.size.height-verticalOffset]; 230 | } 231 | 232 | -(void)flipCoordinateSystemForCoreText { 233 | 234 | CGContextRef context = UIGraphicsGetCurrentContext(); 235 | CGContextSetTextMatrix(context, CGAffineTransformIdentity); 236 | CGContextTranslateCTM(context, 0, self.bounds.size.height); 237 | CGContextScaleCTM(context, 1.0, -1.0); 238 | } 239 | 240 | @end -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo/AFSpritzLabel.m: -------------------------------------------------------------------------------- 1 | // 2 | // AFSpritzLabel.m 3 | // AFSpritz-Demo 4 | // 5 | // Created by Alvaro Franco on 3/1/14. 6 | // Copyright (c) 2014 AlvaroFranco. All rights reserved. 7 | // 8 | 9 | #import "AFSpritzLabel.h" 10 | #import "AFSpritzWords.h" 11 | #import 12 | 13 | typedef enum { 14 | 15 | AFSpritzLabelTextPartHeader, 16 | AFSpritzLabelTextPartMarker, 17 | AFSpritzLabelTextPartTail 18 | } AFSpritzLabelTextPart; 19 | 20 | @implementation AFSpritzLabel { 21 | 22 | CGFloat markerOffset; 23 | CGFloat markerLength; 24 | 25 | CGFloat headerWidth; 26 | CGFloat tailWidth; 27 | CGFloat markerWidth; 28 | 29 | CGFloat textVerticalPosition; 30 | CGFloat textHorizontalPosition; 31 | } 32 | 33 | -(id)initWithFrame:(CGRect)frame { 34 | 35 | if (self == [super initWithFrame:frame]) { 36 | 37 | [self defaultParameters]; 38 | } 39 | 40 | return self; 41 | } 42 | 43 | -(id)initWithCoder:(NSCoder *)aDecoder { 44 | 45 | if (self == [super initWithCoder:aDecoder]) { 46 | 47 | [self defaultParameters]; 48 | } 49 | 50 | return self; 51 | } 52 | 53 | -(void)defaultParameters { 54 | 55 | markerOffset = self.frame.size.width / 3; 56 | markerLength = 5; 57 | textVerticalPosition = 15; 58 | _markerColor = [UIColor redColor]; 59 | _markingLinesColor = [UIColor blackColor]; 60 | _background = [UIColor whiteColor]; 61 | _textColor = [UIColor blackColor]; 62 | _textFont = [UIFont systemFontOfSize:20]; 63 | _word = [[AFSpritzWords alloc] initWithNextWord:@" "]; 64 | 65 | self.layer.cornerRadius = 10; 66 | self.layer.masksToBounds = YES; 67 | self.backgroundColor = _background; 68 | } 69 | 70 | -(void)setWord:(AFSpritzWords *)word { 71 | 72 | if (_word != word) { 73 | 74 | _word = word; 75 | 76 | [self setNeedsDisplay]; 77 | } 78 | } 79 | 80 | -(void)drawRect:(CGRect)rect { 81 | 82 | [super drawRect:rect]; 83 | CGContextRef context = UIGraphicsGetCurrentContext(); 84 | 85 | [self drawMarkingLinesWithOffset:markerOffset andLength:markerLength]; 86 | 87 | [self flipCoordinateSystemForCoreText]; 88 | 89 | CGMutablePathRef path = CGPathCreateMutable(); 90 | CGPathAddRect(path, NULL, self.bounds ); 91 | 92 | NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:self.word.word]; 93 | 94 | [attString addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(self.word.markerPosition, 1)]; 95 | [attString addAttribute:NSFontAttributeName value:self.textFont range:NSMakeRange(0, self.word.word.length)]; 96 | 97 | CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attString); 98 | CTFrameRef frame = CTFramesetterCreateFrame(framesetter,CFRangeMake(0, [attString length]), path, NULL); 99 | 100 | NSArray *lines = (NSArray *)CTFrameGetLines(frame); 101 | 102 | for (id lineObj in lines) { 103 | 104 | CTLineRef line = (__bridge CTLineRef)lineObj; 105 | NSArray *runs = (NSArray *)CTLineGetGlyphRuns(line); 106 | 107 | for (CFIndex runIndex = 0; runIndex < runs.count; ++runIndex) { 108 | 109 | CTRunRef run = (__bridge CTRunRef)[runs objectAtIndex:runIndex]; 110 | CGFloat width = 0; 111 | width = (CGFloat)CTRunGetTypographicBounds(run, CFRangeMake(0, 0), NULL, NULL, NULL); 112 | 113 | switch (runIndex) { 114 | 115 | case AFSpritzLabelTextPartHeader: 116 | headerWidth = width; 117 | 118 | if (runs.count == 1) { 119 | 120 | headerWidth = 0; 121 | markerWidth = width; 122 | [self recomputeTextHorizontalPosition]; 123 | } 124 | 125 | break; 126 | 127 | case AFSpritzLabelTextPartMarker: 128 | markerWidth = width; 129 | 130 | if (runs.count == 2) { 131 | 132 | if (self.word.markerPosition) { 133 | 134 | } else { 135 | 136 | markerWidth = headerWidth; 137 | headerWidth = 0; 138 | markerWidth = width; 139 | } 140 | 141 | [self recomputeTextHorizontalPosition]; 142 | } 143 | 144 | break; 145 | 146 | case AFSpritzLabelTextPartTail: 147 | tailWidth = width; 148 | [self recomputeTextHorizontalPosition]; 149 | break; 150 | 151 | default: 152 | break; 153 | } 154 | } 155 | 156 | for (CFIndex runIndex = 0; runIndex < runs.count; ++runIndex) { 157 | 158 | CTRunRef run = (__bridge CTRunRef)[runs objectAtIndex:runIndex]; 159 | CTFontRef runFont = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName); 160 | 161 | for (CFIndex runGlyphIndex = 0 ; runGlyphIndex < CTRunGetGlyphCount(run) ; runGlyphIndex++) { 162 | 163 | CFRange thisGlyphRange = CFRangeMake(runGlyphIndex, 1); 164 | CGGlyph glyph; 165 | CGPoint position; 166 | CTRunGetGlyphs(run, thisGlyphRange, &glyph); 167 | CTRunGetPositions(run, thisGlyphRange, &position); 168 | 169 | if ((runs.count >= 3 && runIndex == AFSpritzLabelTextPartMarker) || 170 | (runs.count == 1 && !self.word.markerPosition) || 171 | (runs.count == 2 && self.word.markerPosition && runIndex) || 172 | (runs.count == 2 && !self.word.markerPosition && !runIndex)) { 173 | 174 | CGContextSetFillColorWithColor(context, self.markerColor.CGColor); 175 | } else { 176 | 177 | CGContextSetFillColorWithColor(context, self.textColor.CGColor); 178 | } 179 | 180 | position = CGPointMake(position.x + textHorizontalPosition, position.y + textVerticalPosition); 181 | 182 | { 183 | CGFontRef cgFont = CTFontCopyGraphicsFont(runFont, NULL); 184 | 185 | CGAffineTransform textMatrix = CTRunGetTextMatrix(run); 186 | CGContextSetTextMatrix(context, textMatrix); 187 | CGContextSetFont(context, cgFont); 188 | CGContextSetFontSize(context, CTFontGetSize(runFont)); 189 | 190 | CGContextShowGlyphsAtPositions(context, &glyph, &position, 1); 191 | 192 | CFRelease(cgFont); 193 | } 194 | } 195 | } 196 | } 197 | 198 | CFRelease(frame); 199 | CFRelease(path); 200 | CFRelease(framesetter); 201 | } 202 | 203 | -(void)recomputeTextHorizontalPosition { 204 | 205 | textHorizontalPosition = markerOffset - (headerWidth + markerWidth/2.0f); 206 | } 207 | 208 | -(void)drawLineInContextWithWidth:(CGFloat)width fromPointX:(CGFloat)fx fromY:(CGFloat)fy toX:(CGFloat)tx toY:(CGFloat)ty { 209 | 210 | CGContextRef context = UIGraphicsGetCurrentContext(); 211 | CGContextSetLineWidth(context, width); 212 | 213 | CGContextMoveToPoint(context, fx, fy); 214 | CGContextAddLineToPoint(context, tx, ty); 215 | 216 | CGContextStrokePath(context); 217 | } 218 | 219 | -(void)drawMarkingLinesWithOffset:(CGFloat)offset andLength:(CGFloat)length { 220 | 221 | CGFloat verticalOffset = 4.0f; 222 | CGFloat horizontalOffset = 10.0f; 223 | 224 | [self.markingLinesColor set]; 225 | [self drawLineInContextWithWidth:1.0f fromPointX:offset fromY:self.frame.size.height-length - verticalOffset toX:offset toY:self.frame.size.height - verticalOffset]; 226 | [self drawLineInContextWithWidth:1.0f fromPointX:offset fromY:verticalOffset toX:offset toY:length + verticalOffset]; 227 | 228 | [self drawLineInContextWithWidth:2.0f fromPointX:horizontalOffset fromY:verticalOffset toX:self.frame.size.width - horizontalOffset toY:verticalOffset]; 229 | [self drawLineInContextWithWidth:2.0f fromPointX:horizontalOffset fromY:self.frame.size.height-verticalOffset toX:self.frame.size.width - horizontalOffset toY:self.frame.size.height-verticalOffset]; 230 | } 231 | 232 | -(void)flipCoordinateSystemForCoreText { 233 | 234 | CGContextRef context = UIGraphicsGetCurrentContext(); 235 | CGContextSetTextMatrix(context, CGAffineTransformIdentity); 236 | CGContextTranslateCTM(context, 0, self.bounds.size.height); 237 | CGContextScaleCTM(context, 1.0, -1.0); 238 | } 239 | 240 | @end -------------------------------------------------------------------------------- /Demo/AFSpritz-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 | 26 | 34 | 41 | 42 | 43 | 44 | Welcome to AFSpritz! Spritz is a brand new revolutionary reading method that will help you to improve your number of words per minute. Take a look at AFSpritz! By the way! You can use this text or customize it. 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 64 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 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 | 118 | 124 | 130 | 136 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /Demo/AFSpritz-Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A75590CF18C23BFF003D7763 /* AFSpritzLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = A75590CE18C23BFF003D7763 /* AFSpritzLabel.m */; }; 11 | A75590D118C23CF5003D7763 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A75590D018C23CF5003D7763 /* CoreText.framework */; }; 12 | A77A366B18D618F900B2865F /* NSTimer+Control.m in Sources */ = {isa = PBXBuildFile; fileRef = A77A366A18D618F900B2865F /* NSTimer+Control.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 13 | A77AC18518C2360C006368E7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A77AC18418C2360C006368E7 /* Foundation.framework */; }; 14 | A77AC18718C2360C006368E7 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A77AC18618C2360C006368E7 /* CoreGraphics.framework */; }; 15 | A77AC18918C2360C006368E7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A77AC18818C2360C006368E7 /* UIKit.framework */; }; 16 | A77AC18F18C2360C006368E7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A77AC18D18C2360C006368E7 /* InfoPlist.strings */; }; 17 | A77AC19118C2360C006368E7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A77AC19018C2360C006368E7 /* main.m */; }; 18 | A77AC19518C2360C006368E7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A77AC19418C2360C006368E7 /* AppDelegate.m */; }; 19 | A77AC19818C2360C006368E7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A77AC19618C2360C006368E7 /* Main.storyboard */; }; 20 | A77AC19B18C2360C006368E7 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A77AC19A18C2360C006368E7 /* ViewController.m */; }; 21 | A77AC19D18C2360C006368E7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A77AC19C18C2360C006368E7 /* Images.xcassets */; }; 22 | A77AC1A418C2360C006368E7 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A77AC1A318C2360C006368E7 /* XCTest.framework */; }; 23 | A77AC1A518C2360C006368E7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A77AC18418C2360C006368E7 /* Foundation.framework */; }; 24 | A77AC1A618C2360C006368E7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A77AC18818C2360C006368E7 /* UIKit.framework */; }; 25 | A77AC1AE18C2360C006368E7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A77AC1AC18C2360C006368E7 /* InfoPlist.strings */; }; 26 | A77AC1B018C2360C006368E7 /* AFSpritz_DemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A77AC1AF18C2360C006368E7 /* AFSpritz_DemoTests.m */; }; 27 | A77AC1BB18C2363E006368E7 /* AFSpritzManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A77AC1BA18C2363E006368E7 /* AFSpritzManager.m */; }; 28 | A77AC1BF18C2365E006368E7 /* AFSpritzWords.m in Sources */ = {isa = PBXBuildFile; fileRef = A77AC1BE18C2365E006368E7 /* AFSpritzWords.m */; }; 29 | A7B29D8118D8F16300811500 /* SpritzViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A7B29D8018D8F16300811500 /* SpritzViewController.m */; }; 30 | D07A573853A1447E9DDF9AC6 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 53DF1E28854945BD97712B7C /* libPods.a */; }; 31 | /* End PBXBuildFile section */ 32 | 33 | /* Begin PBXContainerItemProxy section */ 34 | A77AC1A718C2360C006368E7 /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = A77AC17918C2360C006368E7 /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = A77AC18018C2360C006368E7; 39 | remoteInfo = "AFSpritz-Demo"; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | 121B0F5E08E04C188CF1F26A /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = ""; }; 45 | 53DF1E28854945BD97712B7C /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | A75590CD18C23BFF003D7763 /* AFSpritzLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFSpritzLabel.h; sourceTree = ""; }; 47 | A75590CE18C23BFF003D7763 /* AFSpritzLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFSpritzLabel.m; sourceTree = ""; }; 48 | A75590D018C23CF5003D7763 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; 49 | A77A366918D618F900B2865F /* NSTimer+Control.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTimer+Control.h"; sourceTree = ""; }; 50 | A77A366A18D618F900B2865F /* NSTimer+Control.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSTimer+Control.m"; sourceTree = ""; }; 51 | A77AC18118C2360C006368E7 /* AFSpritz-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AFSpritz-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | A77AC18418C2360C006368E7 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 53 | A77AC18618C2360C006368E7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 54 | A77AC18818C2360C006368E7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 55 | A77AC18C18C2360C006368E7 /* AFSpritz-Demo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AFSpritz-Demo-Info.plist"; sourceTree = ""; }; 56 | A77AC18E18C2360C006368E7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 57 | A77AC19018C2360C006368E7 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 58 | A77AC19218C2360C006368E7 /* AFSpritz-Demo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AFSpritz-Demo-Prefix.pch"; sourceTree = ""; }; 59 | A77AC19318C2360C006368E7 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 60 | A77AC19418C2360C006368E7 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 61 | A77AC19718C2360C006368E7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 62 | A77AC19918C2360C006368E7 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 63 | A77AC19A18C2360C006368E7 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 64 | A77AC19C18C2360C006368E7 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 65 | A77AC1A218C2360C006368E7 /* AFSpritz-DemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "AFSpritz-DemoTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | A77AC1A318C2360C006368E7 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 67 | A77AC1AB18C2360C006368E7 /* AFSpritz-DemoTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AFSpritz-DemoTests-Info.plist"; sourceTree = ""; }; 68 | A77AC1AD18C2360C006368E7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 69 | A77AC1AF18C2360C006368E7 /* AFSpritz_DemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AFSpritz_DemoTests.m; sourceTree = ""; }; 70 | A77AC1B918C2363E006368E7 /* AFSpritzManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFSpritzManager.h; sourceTree = ""; }; 71 | A77AC1BA18C2363E006368E7 /* AFSpritzManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFSpritzManager.m; sourceTree = ""; }; 72 | A77AC1BD18C2365E006368E7 /* AFSpritzWords.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFSpritzWords.h; sourceTree = ""; }; 73 | A77AC1BE18C2365E006368E7 /* AFSpritzWords.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFSpritzWords.m; sourceTree = ""; }; 74 | A7B29D7F18D8F16300811500 /* SpritzViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpritzViewController.h; sourceTree = ""; }; 75 | A7B29D8018D8F16300811500 /* SpritzViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SpritzViewController.m; sourceTree = ""; }; 76 | /* End PBXFileReference section */ 77 | 78 | /* Begin PBXFrameworksBuildPhase section */ 79 | A77AC17E18C2360C006368E7 /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | A75590D118C23CF5003D7763 /* CoreText.framework in Frameworks */, 84 | A77AC18718C2360C006368E7 /* CoreGraphics.framework in Frameworks */, 85 | A77AC18918C2360C006368E7 /* UIKit.framework in Frameworks */, 86 | A77AC18518C2360C006368E7 /* Foundation.framework in Frameworks */, 87 | D07A573853A1447E9DDF9AC6 /* libPods.a in Frameworks */, 88 | ); 89 | runOnlyForDeploymentPostprocessing = 0; 90 | }; 91 | A77AC19F18C2360C006368E7 /* Frameworks */ = { 92 | isa = PBXFrameworksBuildPhase; 93 | buildActionMask = 2147483647; 94 | files = ( 95 | A77AC1A418C2360C006368E7 /* XCTest.framework in Frameworks */, 96 | A77AC1A618C2360C006368E7 /* UIKit.framework in Frameworks */, 97 | A77AC1A518C2360C006368E7 /* Foundation.framework in Frameworks */, 98 | ); 99 | runOnlyForDeploymentPostprocessing = 0; 100 | }; 101 | /* End PBXFrameworksBuildPhase section */ 102 | 103 | /* Begin PBXGroup section */ 104 | A77AC17818C2360C006368E7 = { 105 | isa = PBXGroup; 106 | children = ( 107 | A77AC18A18C2360C006368E7 /* AFSpritz-Demo */, 108 | A77AC1A918C2360C006368E7 /* AFSpritz-DemoTests */, 109 | A77AC18318C2360C006368E7 /* Frameworks */, 110 | A77AC18218C2360C006368E7 /* Products */, 111 | 121B0F5E08E04C188CF1F26A /* Pods.xcconfig */, 112 | ); 113 | sourceTree = ""; 114 | }; 115 | A77AC18218C2360C006368E7 /* Products */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | A77AC18118C2360C006368E7 /* AFSpritz-Demo.app */, 119 | A77AC1A218C2360C006368E7 /* AFSpritz-DemoTests.xctest */, 120 | ); 121 | name = Products; 122 | sourceTree = ""; 123 | }; 124 | A77AC18318C2360C006368E7 /* Frameworks */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | A75590D018C23CF5003D7763 /* CoreText.framework */, 128 | A77AC18418C2360C006368E7 /* Foundation.framework */, 129 | A77AC18618C2360C006368E7 /* CoreGraphics.framework */, 130 | A77AC18818C2360C006368E7 /* UIKit.framework */, 131 | A77AC1A318C2360C006368E7 /* XCTest.framework */, 132 | 53DF1E28854945BD97712B7C /* libPods.a */, 133 | ); 134 | name = Frameworks; 135 | sourceTree = ""; 136 | }; 137 | A77AC18A18C2360C006368E7 /* AFSpritz-Demo */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | A77AC19318C2360C006368E7 /* AppDelegate.h */, 141 | A77AC19418C2360C006368E7 /* AppDelegate.m */, 142 | A77AC19618C2360C006368E7 /* Main.storyboard */, 143 | A77AC19918C2360C006368E7 /* ViewController.h */, 144 | A77AC19A18C2360C006368E7 /* ViewController.m */, 145 | A7B29D7F18D8F16300811500 /* SpritzViewController.h */, 146 | A7B29D8018D8F16300811500 /* SpritzViewController.m */, 147 | A77AC1BC18C2364C006368E7 /* AFSpritz */, 148 | A77AC19C18C2360C006368E7 /* Images.xcassets */, 149 | A77AC18B18C2360C006368E7 /* Supporting Files */, 150 | ); 151 | path = "AFSpritz-Demo"; 152 | sourceTree = ""; 153 | }; 154 | A77AC18B18C2360C006368E7 /* Supporting Files */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | A77AC18C18C2360C006368E7 /* AFSpritz-Demo-Info.plist */, 158 | A77AC18D18C2360C006368E7 /* InfoPlist.strings */, 159 | A77AC19018C2360C006368E7 /* main.m */, 160 | A77AC19218C2360C006368E7 /* AFSpritz-Demo-Prefix.pch */, 161 | ); 162 | name = "Supporting Files"; 163 | sourceTree = ""; 164 | }; 165 | A77AC1A918C2360C006368E7 /* AFSpritz-DemoTests */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | A77AC1AF18C2360C006368E7 /* AFSpritz_DemoTests.m */, 169 | A77AC1AA18C2360C006368E7 /* Supporting Files */, 170 | ); 171 | path = "AFSpritz-DemoTests"; 172 | sourceTree = ""; 173 | }; 174 | A77AC1AA18C2360C006368E7 /* Supporting Files */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | A77AC1AB18C2360C006368E7 /* AFSpritz-DemoTests-Info.plist */, 178 | A77AC1AC18C2360C006368E7 /* InfoPlist.strings */, 179 | ); 180 | name = "Supporting Files"; 181 | sourceTree = ""; 182 | }; 183 | A77AC1BC18C2364C006368E7 /* AFSpritz */ = { 184 | isa = PBXGroup; 185 | children = ( 186 | A77AC1B918C2363E006368E7 /* AFSpritzManager.h */, 187 | A77AC1BA18C2363E006368E7 /* AFSpritzManager.m */, 188 | A77AC1BD18C2365E006368E7 /* AFSpritzWords.h */, 189 | A77AC1BE18C2365E006368E7 /* AFSpritzWords.m */, 190 | A75590CD18C23BFF003D7763 /* AFSpritzLabel.h */, 191 | A75590CE18C23BFF003D7763 /* AFSpritzLabel.m */, 192 | A77A366918D618F900B2865F /* NSTimer+Control.h */, 193 | A77A366A18D618F900B2865F /* NSTimer+Control.m */, 194 | ); 195 | name = AFSpritz; 196 | sourceTree = ""; 197 | }; 198 | /* End PBXGroup section */ 199 | 200 | /* Begin PBXNativeTarget section */ 201 | A77AC18018C2360C006368E7 /* AFSpritz-Demo */ = { 202 | isa = PBXNativeTarget; 203 | buildConfigurationList = A77AC1B318C2360C006368E7 /* Build configuration list for PBXNativeTarget "AFSpritz-Demo" */; 204 | buildPhases = ( 205 | B0987A504FCF41E2BC730F6A /* Check Pods Manifest.lock */, 206 | A77AC17D18C2360C006368E7 /* Sources */, 207 | A77AC17E18C2360C006368E7 /* Frameworks */, 208 | A77AC17F18C2360C006368E7 /* Resources */, 209 | 42838B07B0C049E0BFE2B50F /* Copy Pods Resources */, 210 | ); 211 | buildRules = ( 212 | ); 213 | dependencies = ( 214 | ); 215 | name = "AFSpritz-Demo"; 216 | productName = "AFSpritz-Demo"; 217 | productReference = A77AC18118C2360C006368E7 /* AFSpritz-Demo.app */; 218 | productType = "com.apple.product-type.application"; 219 | }; 220 | A77AC1A118C2360C006368E7 /* AFSpritz-DemoTests */ = { 221 | isa = PBXNativeTarget; 222 | buildConfigurationList = A77AC1B618C2360C006368E7 /* Build configuration list for PBXNativeTarget "AFSpritz-DemoTests" */; 223 | buildPhases = ( 224 | A77AC19E18C2360C006368E7 /* Sources */, 225 | A77AC19F18C2360C006368E7 /* Frameworks */, 226 | A77AC1A018C2360C006368E7 /* Resources */, 227 | ); 228 | buildRules = ( 229 | ); 230 | dependencies = ( 231 | A77AC1A818C2360C006368E7 /* PBXTargetDependency */, 232 | ); 233 | name = "AFSpritz-DemoTests"; 234 | productName = "AFSpritz-DemoTests"; 235 | productReference = A77AC1A218C2360C006368E7 /* AFSpritz-DemoTests.xctest */; 236 | productType = "com.apple.product-type.bundle.unit-test"; 237 | }; 238 | /* End PBXNativeTarget section */ 239 | 240 | /* Begin PBXProject section */ 241 | A77AC17918C2360C006368E7 /* Project object */ = { 242 | isa = PBXProject; 243 | attributes = { 244 | LastUpgradeCheck = 0620; 245 | ORGANIZATIONNAME = AlvaroFranco; 246 | TargetAttributes = { 247 | A77AC1A118C2360C006368E7 = { 248 | TestTargetID = A77AC18018C2360C006368E7; 249 | }; 250 | }; 251 | }; 252 | buildConfigurationList = A77AC17C18C2360C006368E7 /* Build configuration list for PBXProject "AFSpritz-Demo" */; 253 | compatibilityVersion = "Xcode 3.2"; 254 | developmentRegion = English; 255 | hasScannedForEncodings = 0; 256 | knownRegions = ( 257 | en, 258 | Base, 259 | ); 260 | mainGroup = A77AC17818C2360C006368E7; 261 | productRefGroup = A77AC18218C2360C006368E7 /* Products */; 262 | projectDirPath = ""; 263 | projectRoot = ""; 264 | targets = ( 265 | A77AC18018C2360C006368E7 /* AFSpritz-Demo */, 266 | A77AC1A118C2360C006368E7 /* AFSpritz-DemoTests */, 267 | ); 268 | }; 269 | /* End PBXProject section */ 270 | 271 | /* Begin PBXResourcesBuildPhase section */ 272 | A77AC17F18C2360C006368E7 /* Resources */ = { 273 | isa = PBXResourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | A77AC19D18C2360C006368E7 /* Images.xcassets in Resources */, 277 | A77AC18F18C2360C006368E7 /* InfoPlist.strings in Resources */, 278 | A77AC19818C2360C006368E7 /* Main.storyboard in Resources */, 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | }; 282 | A77AC1A018C2360C006368E7 /* Resources */ = { 283 | isa = PBXResourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | A77AC1AE18C2360C006368E7 /* InfoPlist.strings in Resources */, 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | /* End PBXResourcesBuildPhase section */ 291 | 292 | /* Begin PBXShellScriptBuildPhase section */ 293 | 42838B07B0C049E0BFE2B50F /* Copy Pods Resources */ = { 294 | isa = PBXShellScriptBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | ); 298 | inputPaths = ( 299 | ); 300 | name = "Copy Pods Resources"; 301 | outputPaths = ( 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | shellPath = /bin/sh; 305 | shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n"; 306 | showEnvVarsInLog = 0; 307 | }; 308 | B0987A504FCF41E2BC730F6A /* Check Pods Manifest.lock */ = { 309 | isa = PBXShellScriptBuildPhase; 310 | buildActionMask = 2147483647; 311 | files = ( 312 | ); 313 | inputPaths = ( 314 | ); 315 | name = "Check Pods Manifest.lock"; 316 | outputPaths = ( 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | shellPath = /bin/sh; 320 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 321 | showEnvVarsInLog = 0; 322 | }; 323 | /* End PBXShellScriptBuildPhase section */ 324 | 325 | /* Begin PBXSourcesBuildPhase section */ 326 | A77AC17D18C2360C006368E7 /* Sources */ = { 327 | isa = PBXSourcesBuildPhase; 328 | buildActionMask = 2147483647; 329 | files = ( 330 | A77AC19B18C2360C006368E7 /* ViewController.m in Sources */, 331 | A77AC19518C2360C006368E7 /* AppDelegate.m in Sources */, 332 | A75590CF18C23BFF003D7763 /* AFSpritzLabel.m in Sources */, 333 | A77AC1BF18C2365E006368E7 /* AFSpritzWords.m in Sources */, 334 | A77AC1BB18C2363E006368E7 /* AFSpritzManager.m in Sources */, 335 | A77AC19118C2360C006368E7 /* main.m in Sources */, 336 | A77A366B18D618F900B2865F /* NSTimer+Control.m in Sources */, 337 | A7B29D8118D8F16300811500 /* SpritzViewController.m in Sources */, 338 | ); 339 | runOnlyForDeploymentPostprocessing = 0; 340 | }; 341 | A77AC19E18C2360C006368E7 /* Sources */ = { 342 | isa = PBXSourcesBuildPhase; 343 | buildActionMask = 2147483647; 344 | files = ( 345 | A77AC1B018C2360C006368E7 /* AFSpritz_DemoTests.m in Sources */, 346 | ); 347 | runOnlyForDeploymentPostprocessing = 0; 348 | }; 349 | /* End PBXSourcesBuildPhase section */ 350 | 351 | /* Begin PBXTargetDependency section */ 352 | A77AC1A818C2360C006368E7 /* PBXTargetDependency */ = { 353 | isa = PBXTargetDependency; 354 | target = A77AC18018C2360C006368E7 /* AFSpritz-Demo */; 355 | targetProxy = A77AC1A718C2360C006368E7 /* PBXContainerItemProxy */; 356 | }; 357 | /* End PBXTargetDependency section */ 358 | 359 | /* Begin PBXVariantGroup section */ 360 | A77AC18D18C2360C006368E7 /* InfoPlist.strings */ = { 361 | isa = PBXVariantGroup; 362 | children = ( 363 | A77AC18E18C2360C006368E7 /* en */, 364 | ); 365 | name = InfoPlist.strings; 366 | sourceTree = ""; 367 | }; 368 | A77AC19618C2360C006368E7 /* Main.storyboard */ = { 369 | isa = PBXVariantGroup; 370 | children = ( 371 | A77AC19718C2360C006368E7 /* Base */, 372 | ); 373 | name = Main.storyboard; 374 | sourceTree = ""; 375 | }; 376 | A77AC1AC18C2360C006368E7 /* InfoPlist.strings */ = { 377 | isa = PBXVariantGroup; 378 | children = ( 379 | A77AC1AD18C2360C006368E7 /* en */, 380 | ); 381 | name = InfoPlist.strings; 382 | sourceTree = ""; 383 | }; 384 | /* End PBXVariantGroup section */ 385 | 386 | /* Begin XCBuildConfiguration section */ 387 | A77AC1B118C2360C006368E7 /* Debug */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | ALWAYS_SEARCH_USER_PATHS = NO; 391 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 392 | CLANG_CXX_LIBRARY = "libc++"; 393 | CLANG_ENABLE_MODULES = YES; 394 | CLANG_ENABLE_OBJC_ARC = YES; 395 | CLANG_WARN_BOOL_CONVERSION = YES; 396 | CLANG_WARN_CONSTANT_CONVERSION = YES; 397 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 398 | CLANG_WARN_EMPTY_BODY = YES; 399 | CLANG_WARN_ENUM_CONVERSION = YES; 400 | CLANG_WARN_INT_CONVERSION = YES; 401 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 402 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 403 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 404 | COPY_PHASE_STRIP = NO; 405 | GCC_C_LANGUAGE_STANDARD = gnu99; 406 | GCC_DYNAMIC_NO_PIC = NO; 407 | GCC_OPTIMIZATION_LEVEL = 0; 408 | GCC_PREPROCESSOR_DEFINITIONS = ( 409 | "DEBUG=1", 410 | "$(inherited)", 411 | ); 412 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 413 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 414 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 415 | GCC_WARN_UNDECLARED_SELECTOR = YES; 416 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 417 | GCC_WARN_UNUSED_FUNCTION = YES; 418 | GCC_WARN_UNUSED_VARIABLE = YES; 419 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 420 | ONLY_ACTIVE_ARCH = YES; 421 | SDKROOT = iphoneos; 422 | }; 423 | name = Debug; 424 | }; 425 | A77AC1B218C2360C006368E7 /* Release */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | ALWAYS_SEARCH_USER_PATHS = NO; 429 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 430 | CLANG_CXX_LIBRARY = "libc++"; 431 | CLANG_ENABLE_MODULES = YES; 432 | CLANG_ENABLE_OBJC_ARC = YES; 433 | CLANG_WARN_BOOL_CONVERSION = YES; 434 | CLANG_WARN_CONSTANT_CONVERSION = YES; 435 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 436 | CLANG_WARN_EMPTY_BODY = YES; 437 | CLANG_WARN_ENUM_CONVERSION = YES; 438 | CLANG_WARN_INT_CONVERSION = YES; 439 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 440 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 441 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 442 | COPY_PHASE_STRIP = YES; 443 | ENABLE_NS_ASSERTIONS = NO; 444 | GCC_C_LANGUAGE_STANDARD = gnu99; 445 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 446 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 447 | GCC_WARN_UNDECLARED_SELECTOR = YES; 448 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 449 | GCC_WARN_UNUSED_FUNCTION = YES; 450 | GCC_WARN_UNUSED_VARIABLE = YES; 451 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 452 | SDKROOT = iphoneos; 453 | VALIDATE_PRODUCT = YES; 454 | }; 455 | name = Release; 456 | }; 457 | A77AC1B418C2360C006368E7 /* Debug */ = { 458 | isa = XCBuildConfiguration; 459 | baseConfigurationReference = 121B0F5E08E04C188CF1F26A /* Pods.xcconfig */; 460 | buildSettings = { 461 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 462 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 463 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 464 | GCC_PREFIX_HEADER = "AFSpritz-Demo/AFSpritz-Demo-Prefix.pch"; 465 | INFOPLIST_FILE = "AFSpritz-Demo/AFSpritz-Demo-Info.plist"; 466 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 467 | PRODUCT_NAME = "$(TARGET_NAME)"; 468 | WRAPPER_EXTENSION = app; 469 | }; 470 | name = Debug; 471 | }; 472 | A77AC1B518C2360C006368E7 /* Release */ = { 473 | isa = XCBuildConfiguration; 474 | baseConfigurationReference = 121B0F5E08E04C188CF1F26A /* Pods.xcconfig */; 475 | buildSettings = { 476 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 477 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 478 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 479 | GCC_PREFIX_HEADER = "AFSpritz-Demo/AFSpritz-Demo-Prefix.pch"; 480 | INFOPLIST_FILE = "AFSpritz-Demo/AFSpritz-Demo-Info.plist"; 481 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 482 | PRODUCT_NAME = "$(TARGET_NAME)"; 483 | WRAPPER_EXTENSION = app; 484 | }; 485 | name = Release; 486 | }; 487 | A77AC1B718C2360C006368E7 /* Debug */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AFSpritz-Demo.app/AFSpritz-Demo"; 491 | FRAMEWORK_SEARCH_PATHS = ( 492 | "$(SDKROOT)/Developer/Library/Frameworks", 493 | "$(inherited)", 494 | "$(DEVELOPER_FRAMEWORKS_DIR)", 495 | ); 496 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 497 | GCC_PREFIX_HEADER = "AFSpritz-Demo/AFSpritz-Demo-Prefix.pch"; 498 | GCC_PREPROCESSOR_DEFINITIONS = ( 499 | "DEBUG=1", 500 | "$(inherited)", 501 | ); 502 | INFOPLIST_FILE = "AFSpritz-DemoTests/AFSpritz-DemoTests-Info.plist"; 503 | PRODUCT_NAME = "$(TARGET_NAME)"; 504 | TEST_HOST = "$(BUNDLE_LOADER)"; 505 | WRAPPER_EXTENSION = xctest; 506 | }; 507 | name = Debug; 508 | }; 509 | A77AC1B818C2360C006368E7 /* Release */ = { 510 | isa = XCBuildConfiguration; 511 | buildSettings = { 512 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AFSpritz-Demo.app/AFSpritz-Demo"; 513 | FRAMEWORK_SEARCH_PATHS = ( 514 | "$(SDKROOT)/Developer/Library/Frameworks", 515 | "$(inherited)", 516 | "$(DEVELOPER_FRAMEWORKS_DIR)", 517 | ); 518 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 519 | GCC_PREFIX_HEADER = "AFSpritz-Demo/AFSpritz-Demo-Prefix.pch"; 520 | INFOPLIST_FILE = "AFSpritz-DemoTests/AFSpritz-DemoTests-Info.plist"; 521 | PRODUCT_NAME = "$(TARGET_NAME)"; 522 | TEST_HOST = "$(BUNDLE_LOADER)"; 523 | WRAPPER_EXTENSION = xctest; 524 | }; 525 | name = Release; 526 | }; 527 | /* End XCBuildConfiguration section */ 528 | 529 | /* Begin XCConfigurationList section */ 530 | A77AC17C18C2360C006368E7 /* Build configuration list for PBXProject "AFSpritz-Demo" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | A77AC1B118C2360C006368E7 /* Debug */, 534 | A77AC1B218C2360C006368E7 /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | defaultConfigurationName = Release; 538 | }; 539 | A77AC1B318C2360C006368E7 /* Build configuration list for PBXNativeTarget "AFSpritz-Demo" */ = { 540 | isa = XCConfigurationList; 541 | buildConfigurations = ( 542 | A77AC1B418C2360C006368E7 /* Debug */, 543 | A77AC1B518C2360C006368E7 /* Release */, 544 | ); 545 | defaultConfigurationIsVisible = 0; 546 | defaultConfigurationName = Release; 547 | }; 548 | A77AC1B618C2360C006368E7 /* Build configuration list for PBXNativeTarget "AFSpritz-DemoTests" */ = { 549 | isa = XCConfigurationList; 550 | buildConfigurations = ( 551 | A77AC1B718C2360C006368E7 /* Debug */, 552 | A77AC1B818C2360C006368E7 /* Release */, 553 | ); 554 | defaultConfigurationIsVisible = 0; 555 | defaultConfigurationName = Release; 556 | }; 557 | /* End XCConfigurationList section */ 558 | }; 559 | rootObject = A77AC17918C2360C006368E7 /* Project object */; 560 | } 561 | --------------------------------------------------------------------------------