├── README.md ├── ReadableTextColorByImage.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── ray.xcuserdatad │ └── xcschemes │ ├── ReadableTextColorByImage.xcscheme │ └── xcschememanagement.plist ├── ReadableTextColorByImage ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon-ipad_29.png │ │ ├── icon-ipad_29@2x.png │ │ ├── icon-ipad_40.png │ │ ├── icon-ipad_40@2x.png │ │ ├── icon-ipad_50.png │ │ ├── icon-ipad_50@2x.png │ │ ├── icon-ipad_72.png │ │ ├── icon-ipad_72@2x.png │ │ ├── icon-ipad_76.png │ │ ├── icon-ipad_76@2x.png │ │ ├── icon-iphone_29.png │ │ ├── icon-iphone_29@2x.png │ │ ├── icon-iphone_29@3x.png │ │ ├── icon-iphone_40@2x.png │ │ ├── icon-iphone_40@3x.png │ │ ├── icon-iphone_57.png │ │ ├── icon-iphone_57@2x.png │ │ ├── icon-iphone_60@2x.png │ │ └── icon-iphone_60@3x.png │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── Info.plist ├── Main.storyboard └── ViewController.swift ├── readme-icon.png └── readme-screen.jpg /README.md: -------------------------------------------------------------------------------- 1 | ## Readable text color by image 2 | ### Swift newbie experiment. 3 | 4 | ![](readme-icon.png) 5 | 6 | ![](readme-screen.jpg) 7 | 8 | 9 | -------------------------------------------------------------------------------- /ReadableTextColorByImage.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 71640ED11BB2E6D600D9F0DC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71640ED01BB2E6D600D9F0DC /* AppDelegate.swift */; }; 11 | 71640ED31BB2E6D600D9F0DC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71640ED21BB2E6D600D9F0DC /* ViewController.swift */; }; 12 | 71640ED81BB2E6D600D9F0DC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 71640ED71BB2E6D600D9F0DC /* Assets.xcassets */; }; 13 | 71640EDB1BB2E6D600D9F0DC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71640ED91BB2E6D600D9F0DC /* LaunchScreen.storyboard */; }; 14 | 71640EE31BB2E75100D9F0DC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71640EE21BB2E75100D9F0DC /* Main.storyboard */; settings = {ASSET_TAGS = (); }; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 71640ECD1BB2E6D600D9F0DC /* ReadableTextColorByImage.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ReadableTextColorByImage.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 71640ED01BB2E6D600D9F0DC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 20 | 71640ED21BB2E6D600D9F0DC /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 21 | 71640ED71BB2E6D600D9F0DC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | 71640EDA1BB2E6D600D9F0DC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 23 | 71640EDC1BB2E6D600D9F0DC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | 71640EE21BB2E75100D9F0DC /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | 71640ECA1BB2E6D600D9F0DC /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 71640EC41BB2E6D600D9F0DC = { 39 | isa = PBXGroup; 40 | children = ( 41 | 71640ECF1BB2E6D600D9F0DC /* ReadableTextColorByImage */, 42 | 71640ECE1BB2E6D600D9F0DC /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 71640ECE1BB2E6D600D9F0DC /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 71640ECD1BB2E6D600D9F0DC /* ReadableTextColorByImage.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 71640ECF1BB2E6D600D9F0DC /* ReadableTextColorByImage */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 71640ED01BB2E6D600D9F0DC /* AppDelegate.swift */, 58 | 71640ED21BB2E6D600D9F0DC /* ViewController.swift */, 59 | 71640EE21BB2E75100D9F0DC /* Main.storyboard */, 60 | 71640ED71BB2E6D600D9F0DC /* Assets.xcassets */, 61 | 71640ED91BB2E6D600D9F0DC /* LaunchScreen.storyboard */, 62 | 71640EDC1BB2E6D600D9F0DC /* Info.plist */, 63 | ); 64 | path = ReadableTextColorByImage; 65 | sourceTree = ""; 66 | }; 67 | /* End PBXGroup section */ 68 | 69 | /* Begin PBXNativeTarget section */ 70 | 71640ECC1BB2E6D600D9F0DC /* ReadableTextColorByImage */ = { 71 | isa = PBXNativeTarget; 72 | buildConfigurationList = 71640EDF1BB2E6D600D9F0DC /* Build configuration list for PBXNativeTarget "ReadableTextColorByImage" */; 73 | buildPhases = ( 74 | 71640EC91BB2E6D600D9F0DC /* Sources */, 75 | 71640ECA1BB2E6D600D9F0DC /* Frameworks */, 76 | 71640ECB1BB2E6D600D9F0DC /* Resources */, 77 | ); 78 | buildRules = ( 79 | ); 80 | dependencies = ( 81 | ); 82 | name = ReadableTextColorByImage; 83 | productName = ReadableTextColorByImage; 84 | productReference = 71640ECD1BB2E6D600D9F0DC /* ReadableTextColorByImage.app */; 85 | productType = "com.apple.product-type.application"; 86 | }; 87 | /* End PBXNativeTarget section */ 88 | 89 | /* Begin PBXProject section */ 90 | 71640EC51BB2E6D600D9F0DC /* Project object */ = { 91 | isa = PBXProject; 92 | attributes = { 93 | LastUpgradeCheck = 0700; 94 | ORGANIZATIONNAME = RayPS; 95 | TargetAttributes = { 96 | 71640ECC1BB2E6D600D9F0DC = { 97 | CreatedOnToolsVersion = 7.0; 98 | }; 99 | }; 100 | }; 101 | buildConfigurationList = 71640EC81BB2E6D600D9F0DC /* Build configuration list for PBXProject "ReadableTextColorByImage" */; 102 | compatibilityVersion = "Xcode 3.2"; 103 | developmentRegion = English; 104 | hasScannedForEncodings = 0; 105 | knownRegions = ( 106 | en, 107 | Base, 108 | ); 109 | mainGroup = 71640EC41BB2E6D600D9F0DC; 110 | productRefGroup = 71640ECE1BB2E6D600D9F0DC /* Products */; 111 | projectDirPath = ""; 112 | projectRoot = ""; 113 | targets = ( 114 | 71640ECC1BB2E6D600D9F0DC /* ReadableTextColorByImage */, 115 | ); 116 | }; 117 | /* End PBXProject section */ 118 | 119 | /* Begin PBXResourcesBuildPhase section */ 120 | 71640ECB1BB2E6D600D9F0DC /* Resources */ = { 121 | isa = PBXResourcesBuildPhase; 122 | buildActionMask = 2147483647; 123 | files = ( 124 | 71640EE31BB2E75100D9F0DC /* Main.storyboard in Resources */, 125 | 71640EDB1BB2E6D600D9F0DC /* LaunchScreen.storyboard in Resources */, 126 | 71640ED81BB2E6D600D9F0DC /* Assets.xcassets in Resources */, 127 | ); 128 | runOnlyForDeploymentPostprocessing = 0; 129 | }; 130 | /* End PBXResourcesBuildPhase section */ 131 | 132 | /* Begin PBXSourcesBuildPhase section */ 133 | 71640EC91BB2E6D600D9F0DC /* Sources */ = { 134 | isa = PBXSourcesBuildPhase; 135 | buildActionMask = 2147483647; 136 | files = ( 137 | 71640ED31BB2E6D600D9F0DC /* ViewController.swift in Sources */, 138 | 71640ED11BB2E6D600D9F0DC /* AppDelegate.swift in Sources */, 139 | ); 140 | runOnlyForDeploymentPostprocessing = 0; 141 | }; 142 | /* End PBXSourcesBuildPhase section */ 143 | 144 | /* Begin PBXVariantGroup section */ 145 | 71640ED91BB2E6D600D9F0DC /* LaunchScreen.storyboard */ = { 146 | isa = PBXVariantGroup; 147 | children = ( 148 | 71640EDA1BB2E6D600D9F0DC /* Base */, 149 | ); 150 | name = LaunchScreen.storyboard; 151 | sourceTree = ""; 152 | }; 153 | /* End PBXVariantGroup section */ 154 | 155 | /* Begin XCBuildConfiguration section */ 156 | 71640EDD1BB2E6D600D9F0DC /* Debug */ = { 157 | isa = XCBuildConfiguration; 158 | buildSettings = { 159 | ALWAYS_SEARCH_USER_PATHS = NO; 160 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 161 | CLANG_CXX_LIBRARY = "libc++"; 162 | CLANG_ENABLE_MODULES = YES; 163 | CLANG_ENABLE_OBJC_ARC = YES; 164 | CLANG_WARN_BOOL_CONVERSION = YES; 165 | CLANG_WARN_CONSTANT_CONVERSION = YES; 166 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 167 | CLANG_WARN_EMPTY_BODY = YES; 168 | CLANG_WARN_ENUM_CONVERSION = YES; 169 | CLANG_WARN_INT_CONVERSION = YES; 170 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 171 | CLANG_WARN_UNREACHABLE_CODE = YES; 172 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 173 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 174 | COPY_PHASE_STRIP = NO; 175 | DEBUG_INFORMATION_FORMAT = dwarf; 176 | ENABLE_STRICT_OBJC_MSGSEND = YES; 177 | ENABLE_TESTABILITY = YES; 178 | GCC_C_LANGUAGE_STANDARD = gnu99; 179 | GCC_DYNAMIC_NO_PIC = NO; 180 | GCC_NO_COMMON_BLOCKS = YES; 181 | GCC_OPTIMIZATION_LEVEL = 0; 182 | GCC_PREPROCESSOR_DEFINITIONS = ( 183 | "DEBUG=1", 184 | "$(inherited)", 185 | ); 186 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 187 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 188 | GCC_WARN_UNDECLARED_SELECTOR = YES; 189 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 190 | GCC_WARN_UNUSED_FUNCTION = YES; 191 | GCC_WARN_UNUSED_VARIABLE = YES; 192 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 193 | MTL_ENABLE_DEBUG_INFO = YES; 194 | ONLY_ACTIVE_ARCH = YES; 195 | SDKROOT = iphoneos; 196 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 197 | TARGETED_DEVICE_FAMILY = "1,2"; 198 | }; 199 | name = Debug; 200 | }; 201 | 71640EDE1BB2E6D600D9F0DC /* Release */ = { 202 | isa = XCBuildConfiguration; 203 | buildSettings = { 204 | ALWAYS_SEARCH_USER_PATHS = NO; 205 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 206 | CLANG_CXX_LIBRARY = "libc++"; 207 | CLANG_ENABLE_MODULES = YES; 208 | CLANG_ENABLE_OBJC_ARC = YES; 209 | CLANG_WARN_BOOL_CONVERSION = YES; 210 | CLANG_WARN_CONSTANT_CONVERSION = YES; 211 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 212 | CLANG_WARN_EMPTY_BODY = YES; 213 | CLANG_WARN_ENUM_CONVERSION = YES; 214 | CLANG_WARN_INT_CONVERSION = YES; 215 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 216 | CLANG_WARN_UNREACHABLE_CODE = YES; 217 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 218 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 219 | COPY_PHASE_STRIP = NO; 220 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 221 | ENABLE_NS_ASSERTIONS = NO; 222 | ENABLE_STRICT_OBJC_MSGSEND = YES; 223 | GCC_C_LANGUAGE_STANDARD = gnu99; 224 | GCC_NO_COMMON_BLOCKS = YES; 225 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 226 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 227 | GCC_WARN_UNDECLARED_SELECTOR = YES; 228 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 229 | GCC_WARN_UNUSED_FUNCTION = YES; 230 | GCC_WARN_UNUSED_VARIABLE = YES; 231 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 232 | MTL_ENABLE_DEBUG_INFO = NO; 233 | SDKROOT = iphoneos; 234 | TARGETED_DEVICE_FAMILY = "1,2"; 235 | VALIDATE_PRODUCT = YES; 236 | }; 237 | name = Release; 238 | }; 239 | 71640EE01BB2E6D600D9F0DC /* Debug */ = { 240 | isa = XCBuildConfiguration; 241 | buildSettings = { 242 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 243 | INFOPLIST_FILE = ReadableTextColorByImage/Info.plist; 244 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 245 | PRODUCT_BUNDLE_IDENTIFIER = com.rayps.ReadableTextColorByImage; 246 | PRODUCT_NAME = "$(TARGET_NAME)"; 247 | }; 248 | name = Debug; 249 | }; 250 | 71640EE11BB2E6D600D9F0DC /* Release */ = { 251 | isa = XCBuildConfiguration; 252 | buildSettings = { 253 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 254 | INFOPLIST_FILE = ReadableTextColorByImage/Info.plist; 255 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 256 | PRODUCT_BUNDLE_IDENTIFIER = com.rayps.ReadableTextColorByImage; 257 | PRODUCT_NAME = "$(TARGET_NAME)"; 258 | }; 259 | name = Release; 260 | }; 261 | /* End XCBuildConfiguration section */ 262 | 263 | /* Begin XCConfigurationList section */ 264 | 71640EC81BB2E6D600D9F0DC /* Build configuration list for PBXProject "ReadableTextColorByImage" */ = { 265 | isa = XCConfigurationList; 266 | buildConfigurations = ( 267 | 71640EDD1BB2E6D600D9F0DC /* Debug */, 268 | 71640EDE1BB2E6D600D9F0DC /* Release */, 269 | ); 270 | defaultConfigurationIsVisible = 0; 271 | defaultConfigurationName = Release; 272 | }; 273 | 71640EDF1BB2E6D600D9F0DC /* Build configuration list for PBXNativeTarget "ReadableTextColorByImage" */ = { 274 | isa = XCConfigurationList; 275 | buildConfigurations = ( 276 | 71640EE01BB2E6D600D9F0DC /* Debug */, 277 | 71640EE11BB2E6D600D9F0DC /* Release */, 278 | ); 279 | defaultConfigurationIsVisible = 0; 280 | }; 281 | /* End XCConfigurationList section */ 282 | }; 283 | rootObject = 71640EC51BB2E6D600D9F0DC /* Project object */; 284 | } 285 | -------------------------------------------------------------------------------- /ReadableTextColorByImage.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ReadableTextColorByImage.xcodeproj/xcuserdata/ray.xcuserdatad/xcschemes/ReadableTextColorByImage.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ReadableTextColorByImage.xcodeproj/xcuserdata/ray.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ReadableTextColorByImage.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 71640ECC1BB2E6D600D9F0DC 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ReadableTextColorByImage/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ReadableTextColorByImage 4 | // 5 | // Created by Ray on 9/23/15. 6 | // Copyright © 2015 RayPS. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 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 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "icon-iphone_29.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "icon-iphone_29@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "icon-iphone_29@3x.png", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "icon-iphone_40@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "icon-iphone_40@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "57x57", 35 | "idiom" : "iphone", 36 | "filename" : "icon-iphone_57.png", 37 | "scale" : "1x" 38 | }, 39 | { 40 | "size" : "57x57", 41 | "idiom" : "iphone", 42 | "filename" : "icon-iphone_57@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "icon-iphone_60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "icon-iphone_60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "29x29", 59 | "idiom" : "ipad", 60 | "filename" : "icon-ipad_29.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "icon-ipad_29@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "40x40", 71 | "idiom" : "ipad", 72 | "filename" : "icon-ipad_40.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "icon-ipad_40@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "50x50", 83 | "idiom" : "ipad", 84 | "filename" : "icon-ipad_50.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "50x50", 89 | "idiom" : "ipad", 90 | "filename" : "icon-ipad_50@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "72x72", 95 | "idiom" : "ipad", 96 | "filename" : "icon-ipad_72.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "72x72", 101 | "idiom" : "ipad", 102 | "filename" : "icon-ipad_72@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "76x76", 107 | "idiom" : "ipad", 108 | "filename" : "icon-ipad_76.png", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "size" : "76x76", 113 | "idiom" : "ipad", 114 | "filename" : "icon-ipad_76@2x.png", 115 | "scale" : "2x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_29.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_29@2x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_40.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_40@2x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_50.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_50@2x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_72.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_72@2x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_76.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-ipad_76@2x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_29.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_29@2x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_29@3x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_40@2x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_40@3x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_57.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_57@2x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_60@2x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/ReadableTextColorByImage/Assets.xcassets/AppIcon.appiconset/icon-iphone_60@3x.png -------------------------------------------------------------------------------- /ReadableTextColorByImage/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ReadableTextColorByImage/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ReadableTextColorByImage/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ReadableTextColorByImage/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /ReadableTextColorByImage/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ReadableTextColorByImage 4 | // 5 | // Created by Ray on 9/23/15. 6 | // Copyright © 2015 RayPS. All rights reserved. 7 | // 8 | 9 | 10 | import UIKit 11 | //import QuartzCore 12 | 13 | class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate { 14 | 15 | var selectedImage: UIImage? 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | override func didReceiveMemoryWarning() { 23 | super.didReceiveMemoryWarning() 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | @IBOutlet weak var screenButton: UIButton! 28 | 29 | 30 | var imagePicker = UIImagePickerController() 31 | 32 | 33 | 34 | func imagePickerController(imagePicker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: AnyObject]) { 35 | 36 | var image: UIImage! 37 | 38 | // fetch the selected image 39 | if imagePicker.allowsEditing { 40 | image = info[UIImagePickerControllerEditedImage] as! UIImage 41 | } else { 42 | image = info[UIImagePickerControllerOriginalImage] as! UIImage 43 | } 44 | 45 | selectedImage = image 46 | 47 | // Do something about image by yourself 48 | 49 | screenButton.setBackgroundImage(image, forState: UIControlState.Normal) 50 | 51 | // dissmiss the image picker controller window 52 | self.dismissViewControllerAnimated(true, completion: nil) 53 | 54 | 55 | 56 | if isLightColor(averageColor()) { 57 | screenButton.tintColor = UIColor.blackColor() 58 | } else { 59 | screenButton.tintColor = UIColor.whiteColor() 60 | } 61 | 62 | } 63 | 64 | func averageColor() -> UIColor { 65 | 66 | let rgba = UnsafeMutablePointer.alloc(4) 67 | let colorSpace: CGColorSpaceRef = CGColorSpaceCreateDeviceRGB()! 68 | let info = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue) 69 | let context: CGContextRef = CGBitmapContextCreate(rgba, 1, 1, 8, 4, colorSpace, info.rawValue)! 70 | 71 | if let selectedImage = selectedImage { 72 | CGContextDrawImage(context, CGRectMake(0, 0, 1, 1), selectedImage.CGImage) 73 | } 74 | 75 | 76 | if rgba[3] > 0 { 77 | 78 | let alpha: CGFloat = CGFloat(rgba[3]) / 255.0 79 | let multiplier: CGFloat = alpha / 255.0 80 | 81 | return UIColor(red: CGFloat(rgba[0]) * multiplier, green: CGFloat(rgba[1]) * multiplier, blue: CGFloat(rgba[2]) * multiplier, alpha: alpha) 82 | 83 | } else { 84 | 85 | return UIColor(red: CGFloat(rgba[0]) / 255.0, green: CGFloat(rgba[1]) / 255.0, blue: CGFloat(rgba[2]) / 255.0, alpha: CGFloat(rgba[3]) / 255.0) 86 | } 87 | } 88 | 89 | func isLightColor(color: UIColor) -> Bool{ 90 | 91 | var white: CGFloat = 0.0 92 | color.getWhite(&white, alpha: nil) 93 | if white >= 0.9 { return true } 94 | else { return false } 95 | } 96 | 97 | 98 | 99 | @IBAction func myButtonDidTouched(sender: AnyObject) { 100 | 101 | if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum){ 102 | 103 | imagePicker.delegate = self 104 | imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum; 105 | imagePicker.allowsEditing = false 106 | 107 | self.presentViewController(imagePicker, animated: true, completion: nil) 108 | } 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /readme-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/readme-icon.png -------------------------------------------------------------------------------- /readme-screen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RayPS/ReadableTextColorByImage/e2fd68e4742a274228b5c92328f60f6819fe8c01/readme-screen.jpg --------------------------------------------------------------------------------