├── .gitignore ├── .travis.yml ├── KPFontPicker Demo ├── KPFontPicker Demo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── KPFontPickerDemoTest.xcscheme ├── KPFontPicker Demo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-60@2x.png │ │ │ ├── Icon-60@3x.png │ │ │ ├── Icon-Small-40@2x.png │ │ │ ├── Icon-Small-40@3x.png │ │ │ ├── Icon-Small@2x.png │ │ │ └── Icon-Small@3x.png │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── KPFontPicker DemoTests │ ├── Info.plist │ └── KPFontPicker_DemoTests.m └── KPFontPicker │ ├── KPFontPicker.h │ └── KPFontPicker.m ├── LICENSE ├── README images └── demo.gif └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | script: 3 | - xctool -project KPFontPicker\ Demo/KPFontPicker\ Demo.xcodeproj -scheme KPFontPickerDemoTest -sdk iphonesimulator 4 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | EDDF77C71B0C107100A10EC6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EDDF77C61B0C107100A10EC6 /* main.m */; }; 11 | EDDF77CA1B0C107100A10EC6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EDDF77C91B0C107100A10EC6 /* AppDelegate.m */; }; 12 | EDDF77CD1B0C107100A10EC6 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EDDF77CC1B0C107100A10EC6 /* ViewController.m */; }; 13 | EDDF77D01B0C107100A10EC6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EDDF77CE1B0C107100A10EC6 /* Main.storyboard */; }; 14 | EDDF77D21B0C107100A10EC6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EDDF77D11B0C107100A10EC6 /* Images.xcassets */; }; 15 | EDDF77D51B0C107100A10EC6 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = EDDF77D31B0C107100A10EC6 /* LaunchScreen.xib */; }; 16 | EDDF77E11B0C107100A10EC6 /* KPFontPicker_DemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = EDDF77E01B0C107100A10EC6 /* KPFontPicker_DemoTests.m */; }; 17 | EDDF77ED1B0C108300A10EC6 /* KPFontPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = EDDF77EC1B0C108300A10EC6 /* KPFontPicker.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | EDDF77DB1B0C107100A10EC6 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = EDDF77B91B0C107100A10EC6 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = EDDF77C01B0C107100A10EC6; 26 | remoteInfo = "KPFontPicker Demo"; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | EDDF77C11B0C107100A10EC6 /* KPFontPicker Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "KPFontPicker Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | EDDF77C51B0C107100A10EC6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | EDDF77C61B0C107100A10EC6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | EDDF77C81B0C107100A10EC6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | EDDF77C91B0C107100A10EC6 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | EDDF77CB1B0C107100A10EC6 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 37 | EDDF77CC1B0C107100A10EC6 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 38 | EDDF77CF1B0C107100A10EC6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | EDDF77D11B0C107100A10EC6 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 40 | EDDF77D41B0C107100A10EC6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 41 | EDDF77DA1B0C107100A10EC6 /* KPFontPicker DemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "KPFontPicker DemoTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | EDDF77DF1B0C107100A10EC6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | EDDF77E01B0C107100A10EC6 /* KPFontPicker_DemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KPFontPicker_DemoTests.m; sourceTree = ""; }; 44 | EDDF77EB1B0C108300A10EC6 /* KPFontPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPFontPicker.h; sourceTree = ""; }; 45 | EDDF77EC1B0C108300A10EC6 /* KPFontPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPFontPicker.m; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | EDDF77BE1B0C107100A10EC6 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | EDDF77D71B0C107100A10EC6 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | EDDF77B81B0C107100A10EC6 = { 67 | isa = PBXGroup; 68 | children = ( 69 | EDDF77EA1B0C108300A10EC6 /* KPFontPicker */, 70 | EDDF77C31B0C107100A10EC6 /* KPFontPicker Demo */, 71 | EDDF77DD1B0C107100A10EC6 /* KPFontPicker DemoTests */, 72 | EDDF77C21B0C107100A10EC6 /* Products */, 73 | ); 74 | sourceTree = ""; 75 | }; 76 | EDDF77C21B0C107100A10EC6 /* Products */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | EDDF77C11B0C107100A10EC6 /* KPFontPicker Demo.app */, 80 | EDDF77DA1B0C107100A10EC6 /* KPFontPicker DemoTests.xctest */, 81 | ); 82 | name = Products; 83 | sourceTree = ""; 84 | }; 85 | EDDF77C31B0C107100A10EC6 /* KPFontPicker Demo */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | EDDF77C81B0C107100A10EC6 /* AppDelegate.h */, 89 | EDDF77C91B0C107100A10EC6 /* AppDelegate.m */, 90 | EDDF77CB1B0C107100A10EC6 /* ViewController.h */, 91 | EDDF77CC1B0C107100A10EC6 /* ViewController.m */, 92 | EDDF77CE1B0C107100A10EC6 /* Main.storyboard */, 93 | EDDF77D11B0C107100A10EC6 /* Images.xcassets */, 94 | EDDF77D31B0C107100A10EC6 /* LaunchScreen.xib */, 95 | EDDF77C41B0C107100A10EC6 /* Supporting Files */, 96 | ); 97 | path = "KPFontPicker Demo"; 98 | sourceTree = ""; 99 | }; 100 | EDDF77C41B0C107100A10EC6 /* Supporting Files */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | EDDF77C51B0C107100A10EC6 /* Info.plist */, 104 | EDDF77C61B0C107100A10EC6 /* main.m */, 105 | ); 106 | name = "Supporting Files"; 107 | sourceTree = ""; 108 | }; 109 | EDDF77DD1B0C107100A10EC6 /* KPFontPicker DemoTests */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | EDDF77E01B0C107100A10EC6 /* KPFontPicker_DemoTests.m */, 113 | EDDF77DE1B0C107100A10EC6 /* Supporting Files */, 114 | ); 115 | path = "KPFontPicker DemoTests"; 116 | sourceTree = ""; 117 | }; 118 | EDDF77DE1B0C107100A10EC6 /* Supporting Files */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | EDDF77DF1B0C107100A10EC6 /* Info.plist */, 122 | ); 123 | name = "Supporting Files"; 124 | sourceTree = ""; 125 | }; 126 | EDDF77EA1B0C108300A10EC6 /* KPFontPicker */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | EDDF77EB1B0C108300A10EC6 /* KPFontPicker.h */, 130 | EDDF77EC1B0C108300A10EC6 /* KPFontPicker.m */, 131 | ); 132 | path = KPFontPicker; 133 | sourceTree = ""; 134 | }; 135 | /* End PBXGroup section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | EDDF77C01B0C107100A10EC6 /* KPFontPicker Demo */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = EDDF77E41B0C107100A10EC6 /* Build configuration list for PBXNativeTarget "KPFontPicker Demo" */; 141 | buildPhases = ( 142 | EDDF77BD1B0C107100A10EC6 /* Sources */, 143 | EDDF77BE1B0C107100A10EC6 /* Frameworks */, 144 | EDDF77BF1B0C107100A10EC6 /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | ); 150 | name = "KPFontPicker Demo"; 151 | productName = "KPFontPicker Demo"; 152 | productReference = EDDF77C11B0C107100A10EC6 /* KPFontPicker Demo.app */; 153 | productType = "com.apple.product-type.application"; 154 | }; 155 | EDDF77D91B0C107100A10EC6 /* KPFontPicker DemoTests */ = { 156 | isa = PBXNativeTarget; 157 | buildConfigurationList = EDDF77E71B0C107100A10EC6 /* Build configuration list for PBXNativeTarget "KPFontPicker DemoTests" */; 158 | buildPhases = ( 159 | EDDF77D61B0C107100A10EC6 /* Sources */, 160 | EDDF77D71B0C107100A10EC6 /* Frameworks */, 161 | EDDF77D81B0C107100A10EC6 /* Resources */, 162 | ); 163 | buildRules = ( 164 | ); 165 | dependencies = ( 166 | EDDF77DC1B0C107100A10EC6 /* PBXTargetDependency */, 167 | ); 168 | name = "KPFontPicker DemoTests"; 169 | productName = "KPFontPicker DemoTests"; 170 | productReference = EDDF77DA1B0C107100A10EC6 /* KPFontPicker DemoTests.xctest */; 171 | productType = "com.apple.product-type.bundle.unit-test"; 172 | }; 173 | /* End PBXNativeTarget section */ 174 | 175 | /* Begin PBXProject section */ 176 | EDDF77B91B0C107100A10EC6 /* Project object */ = { 177 | isa = PBXProject; 178 | attributes = { 179 | LastUpgradeCheck = 0630; 180 | ORGANIZATIONNAME = "Kirill Pahnev"; 181 | TargetAttributes = { 182 | EDDF77C01B0C107100A10EC6 = { 183 | CreatedOnToolsVersion = 6.3; 184 | }; 185 | EDDF77D91B0C107100A10EC6 = { 186 | CreatedOnToolsVersion = 6.3; 187 | TestTargetID = EDDF77C01B0C107100A10EC6; 188 | }; 189 | }; 190 | }; 191 | buildConfigurationList = EDDF77BC1B0C107100A10EC6 /* Build configuration list for PBXProject "KPFontPicker Demo" */; 192 | compatibilityVersion = "Xcode 3.2"; 193 | developmentRegion = English; 194 | hasScannedForEncodings = 0; 195 | knownRegions = ( 196 | en, 197 | Base, 198 | ); 199 | mainGroup = EDDF77B81B0C107100A10EC6; 200 | productRefGroup = EDDF77C21B0C107100A10EC6 /* Products */; 201 | projectDirPath = ""; 202 | projectRoot = ""; 203 | targets = ( 204 | EDDF77C01B0C107100A10EC6 /* KPFontPicker Demo */, 205 | EDDF77D91B0C107100A10EC6 /* KPFontPicker DemoTests */, 206 | ); 207 | }; 208 | /* End PBXProject section */ 209 | 210 | /* Begin PBXResourcesBuildPhase section */ 211 | EDDF77BF1B0C107100A10EC6 /* Resources */ = { 212 | isa = PBXResourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | EDDF77D01B0C107100A10EC6 /* Main.storyboard in Resources */, 216 | EDDF77D51B0C107100A10EC6 /* LaunchScreen.xib in Resources */, 217 | EDDF77D21B0C107100A10EC6 /* Images.xcassets in Resources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | EDDF77D81B0C107100A10EC6 /* Resources */ = { 222 | isa = PBXResourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | /* End PBXResourcesBuildPhase section */ 229 | 230 | /* Begin PBXSourcesBuildPhase section */ 231 | EDDF77BD1B0C107100A10EC6 /* Sources */ = { 232 | isa = PBXSourcesBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | EDDF77CD1B0C107100A10EC6 /* ViewController.m in Sources */, 236 | EDDF77ED1B0C108300A10EC6 /* KPFontPicker.m in Sources */, 237 | EDDF77CA1B0C107100A10EC6 /* AppDelegate.m in Sources */, 238 | EDDF77C71B0C107100A10EC6 /* main.m in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | EDDF77D61B0C107100A10EC6 /* Sources */ = { 243 | isa = PBXSourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | EDDF77E11B0C107100A10EC6 /* KPFontPicker_DemoTests.m in Sources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | /* End PBXSourcesBuildPhase section */ 251 | 252 | /* Begin PBXTargetDependency section */ 253 | EDDF77DC1B0C107100A10EC6 /* PBXTargetDependency */ = { 254 | isa = PBXTargetDependency; 255 | target = EDDF77C01B0C107100A10EC6 /* KPFontPicker Demo */; 256 | targetProxy = EDDF77DB1B0C107100A10EC6 /* PBXContainerItemProxy */; 257 | }; 258 | /* End PBXTargetDependency section */ 259 | 260 | /* Begin PBXVariantGroup section */ 261 | EDDF77CE1B0C107100A10EC6 /* Main.storyboard */ = { 262 | isa = PBXVariantGroup; 263 | children = ( 264 | EDDF77CF1B0C107100A10EC6 /* Base */, 265 | ); 266 | name = Main.storyboard; 267 | sourceTree = ""; 268 | }; 269 | EDDF77D31B0C107100A10EC6 /* LaunchScreen.xib */ = { 270 | isa = PBXVariantGroup; 271 | children = ( 272 | EDDF77D41B0C107100A10EC6 /* Base */, 273 | ); 274 | name = LaunchScreen.xib; 275 | sourceTree = ""; 276 | }; 277 | /* End PBXVariantGroup section */ 278 | 279 | /* Begin XCBuildConfiguration section */ 280 | EDDF77E21B0C107100A10EC6 /* Debug */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ALWAYS_SEARCH_USER_PATHS = NO; 284 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 285 | CLANG_CXX_LIBRARY = "libc++"; 286 | CLANG_ENABLE_MODULES = YES; 287 | CLANG_ENABLE_OBJC_ARC = YES; 288 | CLANG_WARN_BOOL_CONVERSION = YES; 289 | CLANG_WARN_CONSTANT_CONVERSION = YES; 290 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 291 | CLANG_WARN_EMPTY_BODY = YES; 292 | CLANG_WARN_ENUM_CONVERSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 295 | CLANG_WARN_UNREACHABLE_CODE = YES; 296 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 297 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 298 | COPY_PHASE_STRIP = NO; 299 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 300 | ENABLE_STRICT_OBJC_MSGSEND = YES; 301 | GCC_C_LANGUAGE_STANDARD = gnu99; 302 | GCC_DYNAMIC_NO_PIC = NO; 303 | GCC_NO_COMMON_BLOCKS = YES; 304 | GCC_OPTIMIZATION_LEVEL = 0; 305 | GCC_PREPROCESSOR_DEFINITIONS = ( 306 | "DEBUG=1", 307 | "$(inherited)", 308 | ); 309 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 310 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 311 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 312 | GCC_WARN_UNDECLARED_SELECTOR = YES; 313 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 314 | GCC_WARN_UNUSED_FUNCTION = YES; 315 | GCC_WARN_UNUSED_VARIABLE = YES; 316 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 317 | MTL_ENABLE_DEBUG_INFO = YES; 318 | ONLY_ACTIVE_ARCH = YES; 319 | SDKROOT = iphoneos; 320 | }; 321 | name = Debug; 322 | }; 323 | EDDF77E31B0C107100A10EC6 /* Release */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | ALWAYS_SEARCH_USER_PATHS = NO; 327 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 328 | CLANG_CXX_LIBRARY = "libc++"; 329 | CLANG_ENABLE_MODULES = YES; 330 | CLANG_ENABLE_OBJC_ARC = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_CONSTANT_CONVERSION = YES; 333 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 334 | CLANG_WARN_EMPTY_BODY = YES; 335 | CLANG_WARN_ENUM_CONVERSION = YES; 336 | CLANG_WARN_INT_CONVERSION = YES; 337 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 338 | CLANG_WARN_UNREACHABLE_CODE = YES; 339 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 340 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 341 | COPY_PHASE_STRIP = NO; 342 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 343 | ENABLE_NS_ASSERTIONS = NO; 344 | ENABLE_STRICT_OBJC_MSGSEND = YES; 345 | GCC_C_LANGUAGE_STANDARD = gnu99; 346 | GCC_NO_COMMON_BLOCKS = YES; 347 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 348 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 349 | GCC_WARN_UNDECLARED_SELECTOR = YES; 350 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 351 | GCC_WARN_UNUSED_FUNCTION = YES; 352 | GCC_WARN_UNUSED_VARIABLE = YES; 353 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 354 | MTL_ENABLE_DEBUG_INFO = NO; 355 | SDKROOT = iphoneos; 356 | VALIDATE_PRODUCT = YES; 357 | }; 358 | name = Release; 359 | }; 360 | EDDF77E51B0C107100A10EC6 /* Debug */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 364 | INFOPLIST_FILE = "KPFontPicker Demo/Info.plist"; 365 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 366 | PRODUCT_NAME = "$(TARGET_NAME)"; 367 | }; 368 | name = Debug; 369 | }; 370 | EDDF77E61B0C107100A10EC6 /* Release */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 374 | INFOPLIST_FILE = "KPFontPicker Demo/Info.plist"; 375 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 376 | PRODUCT_NAME = "$(TARGET_NAME)"; 377 | }; 378 | name = Release; 379 | }; 380 | EDDF77E81B0C107100A10EC6 /* Debug */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | BUNDLE_LOADER = "$(TEST_HOST)"; 384 | FRAMEWORK_SEARCH_PATHS = ( 385 | "$(SDKROOT)/Developer/Library/Frameworks", 386 | "$(inherited)", 387 | ); 388 | GCC_PREPROCESSOR_DEFINITIONS = ( 389 | "DEBUG=1", 390 | "$(inherited)", 391 | ); 392 | INFOPLIST_FILE = "KPFontPicker DemoTests/Info.plist"; 393 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 394 | PRODUCT_NAME = "$(TARGET_NAME)"; 395 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KPFontPicker Demo.app/KPFontPicker Demo"; 396 | }; 397 | name = Debug; 398 | }; 399 | EDDF77E91B0C107100A10EC6 /* Release */ = { 400 | isa = XCBuildConfiguration; 401 | buildSettings = { 402 | BUNDLE_LOADER = "$(TEST_HOST)"; 403 | FRAMEWORK_SEARCH_PATHS = ( 404 | "$(SDKROOT)/Developer/Library/Frameworks", 405 | "$(inherited)", 406 | ); 407 | INFOPLIST_FILE = "KPFontPicker DemoTests/Info.plist"; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KPFontPicker Demo.app/KPFontPicker Demo"; 411 | }; 412 | name = Release; 413 | }; 414 | /* End XCBuildConfiguration section */ 415 | 416 | /* Begin XCConfigurationList section */ 417 | EDDF77BC1B0C107100A10EC6 /* Build configuration list for PBXProject "KPFontPicker Demo" */ = { 418 | isa = XCConfigurationList; 419 | buildConfigurations = ( 420 | EDDF77E21B0C107100A10EC6 /* Debug */, 421 | EDDF77E31B0C107100A10EC6 /* Release */, 422 | ); 423 | defaultConfigurationIsVisible = 0; 424 | defaultConfigurationName = Release; 425 | }; 426 | EDDF77E41B0C107100A10EC6 /* Build configuration list for PBXNativeTarget "KPFontPicker Demo" */ = { 427 | isa = XCConfigurationList; 428 | buildConfigurations = ( 429 | EDDF77E51B0C107100A10EC6 /* Debug */, 430 | EDDF77E61B0C107100A10EC6 /* Release */, 431 | ); 432 | defaultConfigurationIsVisible = 0; 433 | }; 434 | EDDF77E71B0C107100A10EC6 /* Build configuration list for PBXNativeTarget "KPFontPicker DemoTests" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | EDDF77E81B0C107100A10EC6 /* Debug */, 438 | EDDF77E91B0C107100A10EC6 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | }; 442 | /* End XCConfigurationList section */ 443 | }; 444 | rootObject = EDDF77B91B0C107100A10EC6 /* Project object */; 445 | } 446 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo.xcodeproj/xcshareddata/xcschemes/KPFontPickerDemoTest.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // KPFontPicker Demo 4 | // 5 | // Created by Kirill Pahnev on 19/05/15. 6 | // Copyright (c) 2015 Kirill Pahnev. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // KPFontPicker Demo 4 | // 5 | // Created by Kirill Pahnev on 19/05/15. 6 | // Copyright (c) 2015 Kirill Pahnev. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-Small@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-Small@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-Small-40@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-Small-40@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-60@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-60@3x.png", 37 | "scale" : "3x" 38 | } 39 | ], 40 | "info" : { 41 | "version" : 1, 42 | "author" : "xcode" 43 | } 44 | } -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pahnev/KPFontPicker/160461aaf3cfe13dd24f889f9f1f92514177e215/KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pahnev/KPFontPicker/160461aaf3cfe13dd24f889f9f1f92514177e215/KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pahnev/KPFontPicker/160461aaf3cfe13dd24f889f9f1f92514177e215/KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pahnev/KPFontPicker/160461aaf3cfe13dd24f889f9f1f92514177e215/KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pahnev/KPFontPicker/160461aaf3cfe13dd24f889f9f1f92514177e215/KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pahnev/KPFontPicker/160461aaf3cfe13dd24f889f9f1f92514177e215/KPFontPicker Demo/KPFontPicker Demo/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | cf.pahnev.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // KPFontPicker Demo 4 | // 5 | // Created by Kirill Pahnev on 19/05/15. 6 | // Copyright (c) 2015 Kirill Pahnev. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // KPFontPicker Demo 4 | // 5 | // Created by Kirill Pahnev on 19/05/15. 6 | // Copyright (c) 2015 Kirill Pahnev. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "KPFontPicker.h" 11 | 12 | @interface ViewController () 13 | @property(weak, nonatomic) IBOutlet UITextField *textField; 14 | @property(strong, nonatomic) KPFontPicker *picker; 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad 20 | { 21 | [super viewDidLoad]; 22 | 23 | // Custom list of font. By default it loads all the fonts in the system. 24 | NSArray *fonts = @[ @"AmericanTypewriter", @"Baskerville", @"Copperplate", @"Didot", @"EuphemiaUCAS", @"Futura-Medium", @"GillSans", @"Helvetica", @"Marion-Regular", @"Optima-Regular", @"Palatino-Roman", @"TimesNewRoman", @"Verdana" ]; 25 | 26 | self.picker = [[KPFontPicker alloc] initWithFonts:fonts]; 27 | 28 | self.picker.delegate = self; 29 | self.textField.delegate = self; 30 | self.textField.inputAccessoryView = [self createToolbar]; 31 | } 32 | 33 | #pragma mark - KPFontpicker Delegate 34 | - (void)pickerDidSelectFont:(NSString *)font withSize:(CGFloat)fontSize color:(UIColor *)fontColor 35 | { 36 | self.textField.font = [UIFont fontWithName:font size:fontSize]; 37 | self.textField.textColor = fontColor; 38 | } 39 | 40 | // Optional delegate 41 | - (void)pickerDidSelectFontColor:(UIColor *)fontColor 42 | { 43 | NSLog(@"Color selected %@", fontColor); 44 | } 45 | 46 | #pragma mark - Toolbar 47 | - (UIToolbar *)createToolbar 48 | { 49 | UIToolbar *keyboardDoneButtonView = [[UIToolbar alloc] init]; 50 | keyboardDoneButtonView.barTintColor = [UIColor darkGrayColor]; 51 | keyboardDoneButtonView.tintColor = [UIColor whiteColor]; 52 | [keyboardDoneButtonView sizeToFit]; 53 | 54 | UIBarButtonItem *keyboardButton = [[UIBarButtonItem alloc] initWithTitle:@"Keyboard" 55 | style:UIBarButtonItemStylePlain 56 | target:self 57 | action:@selector(keyboardClicked:)]; 58 | 59 | UIBarButtonItem *fontButton = [[UIBarButtonItem alloc] initWithTitle:@"Font" 60 | style:UIBarButtonItemStylePlain 61 | target:self 62 | action:@selector(pickerClicked:)]; 63 | 64 | UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 65 | 66 | UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone 67 | target:self 68 | action:@selector(doneClicked:)]; 69 | 70 | [keyboardDoneButtonView setItems:[NSArray arrayWithObjects:keyboardButton, fontButton, flex, doneButton, nil]]; 71 | 72 | return keyboardDoneButtonView; 73 | } 74 | 75 | #pragma mark - Toolbar actions 76 | - (IBAction)keyboardClicked:(id)sender 77 | { 78 | if ([self.textField isFirstResponder]) { 79 | self.textField.inputView = nil; 80 | 81 | [self.textField reloadInputViews]; 82 | } 83 | } 84 | 85 | - (IBAction)pickerClicked:(id)sender 86 | { 87 | if ([self.textField isFirstResponder]) { 88 | self.textField.inputView = self.picker; 89 | [self.textField reloadInputViews]; 90 | } 91 | } 92 | 93 | - (IBAction)doneClicked:(id)sender 94 | { 95 | if ([self.textField isFirstResponder]) { 96 | self.textField.inputView = nil; 97 | 98 | [self.textField resignFirstResponder]; 99 | } 100 | } 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // KPFontPicker Demo 4 | // 5 | // Created by Kirill Pahnev on 19/05/15. 6 | // Copyright (c) 2015 Kirill Pahnev. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker DemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | cf.pahnev.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker DemoTests/KPFontPicker_DemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // KPFontPicker_DemoTests.m 3 | // KPFontPicker DemoTests 4 | // 5 | // Created by Kirill Pahnev on 19/05/15. 6 | // Copyright (c) 2015 Kirill Pahnev. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface KPFontPicker_DemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation KPFontPicker_DemoTests 17 | 18 | - (void)setUp { 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 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker/KPFontPicker.h: -------------------------------------------------------------------------------- 1 | // 2 | // KPFontPicker.h 3 | // KPFontPicker 4 | // 5 | // Created by Kirill Pahnev on 20.4.2015. 6 | // Copyright (c) 2015 Kirill Pahnev. All rights reserved. 7 | // 8 | #import 9 | 10 | typedef NS_ENUM(NSInteger, KPFontPickerColorVariants) { 11 | KPFontPickerColorVariantsNone = 0, 12 | KPFontPickerColorVariants222 = 8, 13 | KPFontPickerColorVariants333 = 27, 14 | KPFontPickerColorVariants444 = 64, // default 15 | KPFontPickerColorVariants555 = 125, 16 | KPFontPickerColorVariants666 = 216, // web safe color 17 | }; 18 | 19 | @protocol KPFontPickerDelegate 20 | 21 | /** 22 | @brief Called by the picker view when the user selects a row in any component. 23 | @param font Name of the font selected in the picker. 24 | @param fontSize Size of the font selected in the picker. 25 | @param fontColor Color of the font selected in the picker. 26 | */ 27 | - (void)pickerDidSelectFont:(NSString *)font withSize:(CGFloat)fontSize color:(UIColor *)fontColor; 28 | 29 | @optional 30 | 31 | - (void)pickerDidSelectRow:(NSInteger)row inComponent:(NSInteger)component; 32 | - (void)pickerDidSelectFont:(NSString *)font; 33 | - (void)pickerDidSelectFontSize:(CGFloat)fontSize; 34 | - (void)pickerDidSelectFontColor:(UIColor *)fontColor; 35 | 36 | @end 37 | 38 | @interface KPFontPicker : UIView 39 | 40 | @property(nonatomic, weak) id delegate; 41 | @property(strong, nonatomic) UIPickerView *pickerView; 42 | 43 | @property(strong, nonatomic) NSArray *fontList; 44 | @property(strong, nonatomic) NSArray *sizeList; 45 | @property(strong, nonatomic) NSArray *colorList; 46 | 47 | @property(strong, nonatomic) NSString *fontName; 48 | @property CGFloat fontSize; 49 | @property(strong, nonatomic) UIColor *color; 50 | 51 | @property(strong, nonatomic) UIFont *font; 52 | @property CGFloat minFontSize; 53 | @property CGFloat maxFontSize; 54 | @property CGFloat stepFontSize; 55 | 56 | @property KPFontPickerColorVariants colorVariants; 57 | @property NSInteger grayVariants; 58 | 59 | /** 60 | @brief Simple pickerview to modify elements that contain text. 61 | @param fonts Assign an array of your selected font. 62 | @return A container view which contains the UIPicker with 63 | */ 64 | - (instancetype)initWithFonts:(NSArray *)fonts; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /KPFontPicker Demo/KPFontPicker/KPFontPicker.m: -------------------------------------------------------------------------------- 1 | // 2 | // KPFontPicker.m 3 | // KPFontPicker 4 | // 5 | // Created by Kirill Pahnev on 20.4.2015. 6 | // Copyright (c) 2015 Kirill Pahnev. All rights reserved. 7 | // 8 | 9 | #import "KPFontPicker.h" 10 | 11 | #define kWindowSize [UIScreen mainScreen].bounds.size 12 | 13 | typedef NS_ENUM(NSUInteger, PickerComponents) { 14 | FontComponent, 15 | FontSizeComponent, 16 | FontColorComponent, 17 | }; 18 | 19 | @implementation KPFontPicker 20 | 21 | NSString *const kDefaultFontName = @"Helvetica"; 22 | static const NSInteger kDefaultFontSize = 17; 23 | 24 | static const KPFontPickerColorVariants KPFontPickerColorVariantsDefault = KPFontPickerColorVariants444; 25 | static const NSInteger KPFontPickerGrayVariantsDefault = 3; 26 | 27 | static const CGFloat KPFontPickerMinFontSizeDefault = 8; 28 | static const CGFloat KPFontPickerMaxFontSizeDefault = 72; 29 | static const CGFloat KpFontPickerStepFontSizeDefault = 1; 30 | 31 | static const CGFloat kRowHeight = 30; 32 | 33 | - (instancetype)initWithFonts:(NSArray *)fonts 34 | { 35 | self = [super init]; 36 | if (self) { 37 | 38 | if (!self.pickerView) { 39 | _fontList = fonts; 40 | 41 | self.frame = CGRectMake(0.0, 0.0, kWindowSize.width, 216); 42 | _pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 0.0, kWindowSize.width, 216.0)]; 43 | _pickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 44 | _pickerView.dataSource = self; 45 | _pickerView.delegate = self; 46 | self.backgroundColor = [UIColor colorWithWhite:0.98 alpha:0.98]; 47 | 48 | _pickerView.tintColor = [UIColor blackColor]; 49 | 50 | _pickerView.showsSelectionIndicator = YES; 51 | [self addSubview:_pickerView]; 52 | 53 | [self setInitialPickerValues]; 54 | } 55 | } 56 | return self; 57 | } 58 | 59 | - (instancetype)init 60 | { 61 | return [self initWithFonts:nil]; 62 | } 63 | 64 | - (void)setInitialPickerValues 65 | { 66 | if (!_fontName) { 67 | _fontName = kDefaultFontName; 68 | NSInteger fontRow = [self indexForFontName:_fontName]; 69 | [self.pickerView selectRow:fontRow inComponent:0 animated:YES]; 70 | } 71 | if (!_fontSize) { 72 | _fontSize = kDefaultFontSize; 73 | NSInteger sizeRow = [self indexForFontSize:_fontSize]; 74 | [self.pickerView selectRow:sizeRow inComponent:1 animated:YES]; 75 | } 76 | if (!_color) { 77 | _color = [UIColor blackColor]; 78 | NSInteger row = [self indexForNearestColor:_color]; 79 | [self.pickerView selectRow:row inComponent:2 animated:YES]; 80 | } 81 | } 82 | 83 | - (NSInteger)indexForNearestColor:(UIColor *)color 84 | { 85 | if (!color) 86 | return NSNotFound; 87 | CGFloat r1, g1, b1, a1; 88 | [color getRed:&r1 green:&g1 blue:&b1 alpha:&a1]; 89 | r1 = round(r1 * 255); 90 | g1 = round(g1 * 255); 91 | b1 = round(b1 * 255); 92 | 93 | CGFloat distance = MAXFLOAT; 94 | NSInteger index = NSNotFound; 95 | for (int i = 0; i < self.colorList.count; i++) { 96 | UIColor *testColor = self.colorList[i]; 97 | if (!testColor) 98 | return NSNotFound; 99 | CGFloat r2, g2, b2, a2; 100 | [testColor getRed:&r2 green:&g2 blue:&b2 alpha:&a2]; 101 | r2 = round(r2 * 255); 102 | g2 = round(g2 * 255); 103 | b2 = round(b2 * 255); 104 | 105 | // test RGB color code as 0-255 integer number but not float number 106 | if (r1 == r2 && g1 == g2 && b1 == b2) { 107 | return i; 108 | } 109 | 110 | CGFloat testDist = (r1 - r2) * (r1 - r2) + (g1 - g2) * (g1 - g2) + (b1 - b2) * (b1 - b2); 111 | if (testDist < distance) { 112 | distance = testDist; 113 | index = i; 114 | } 115 | } 116 | return index; 117 | } 118 | 119 | - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView 120 | { 121 | return 3; 122 | } 123 | 124 | #pragma mark - UIPickerView data source 125 | - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component 126 | { 127 | if (component == FontComponent) { 128 | return self.fontList.count; 129 | } else if (component == FontSizeComponent) { 130 | return self.sizeList.count; 131 | } else if (component == FontColorComponent) { 132 | return self.colorList.count; 133 | } 134 | // Something went wrong 135 | return NAN; 136 | } 137 | 138 | - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component 139 | { 140 | if (component == FontComponent) { 141 | return 200; 142 | } else if (component == FontSizeComponent) { 143 | return 60; 144 | } else if (component == FontColorComponent) { 145 | return 60; 146 | } 147 | return NAN; // something wrong 148 | } 149 | 150 | - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component 151 | { 152 | return kRowHeight; 153 | } 154 | 155 | - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view; 156 | { 157 | NSString *string; 158 | CGFloat size = 19; 159 | UIFont *font = [UIFont systemFontOfSize:size]; 160 | UILabel *label = [[UILabel alloc] init]; 161 | label.backgroundColor = [UIColor clearColor]; 162 | label.textColor = [UIColor darkTextColor]; 163 | label.font = [UIFont fontWithName:@"Helvetica-Bold" size:18]; 164 | // CGFloat width = 100; 165 | 166 | if (component == FontComponent) { 167 | if (self.fontList.count <= row) { 168 | return nil; 169 | } 170 | NSString *fontName = self.fontList[row]; 171 | font = [UIFont fontWithName:fontName size:size]; 172 | string = fontName; 173 | label.font = font; 174 | label.frame = CGRectMake(0, 0, kWindowSize.width * 0.6, kRowHeight); 175 | 176 | } else if (component == FontSizeComponent) { 177 | if (self.sizeList.count <= row) { 178 | return nil; 179 | } 180 | NSNumber *fontNumber = self.sizeList[row]; 181 | CGFloat fontSize = fontNumber.floatValue; 182 | if (fontSize == floor(fontSize)) { 183 | string = [NSString stringWithFormat:@"%2.0f", fontSize]; 184 | } else { 185 | string = [NSString stringWithFormat:@"%.1f", fontSize]; 186 | } 187 | label.textAlignment = NSTextAlignmentCenter; 188 | label.frame = CGRectMake(0, 0, kWindowSize.width * 0.4, kRowHeight); 189 | 190 | } else if (component == FontColorComponent) { 191 | if (self.colorList.count <= row) { 192 | return nil; 193 | } 194 | label.backgroundColor = self.colorList[row]; 195 | label.frame = CGRectMake(0, 0, kWindowSize.width * 0.2, kRowHeight); 196 | } 197 | label.text = string; 198 | 199 | return label; 200 | } 201 | 202 | #pragma mark - UIPickerView delegate methods 203 | // Do something with the selected row. 204 | - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 205 | { 206 | // cache current font and color selected 207 | if (component == FontComponent) { 208 | if ([self.delegate respondsToSelector:@selector(pickerDidSelectFont:)]) 209 | [self.delegate pickerDidSelectFont:[self selectedFontName]]; 210 | _fontName = [self selectedFontName]; 211 | } else if (component == FontSizeComponent) { 212 | if ([self.delegate respondsToSelector:@selector(pickerDidSelectFontSize:)]) 213 | [self.delegate pickerDidSelectFontSize:[self selectedFontSize]]; 214 | 215 | _fontSize = [self selectedFontSize]; 216 | 217 | } else if (component == FontColorComponent) { 218 | if ([self.delegate respondsToSelector:@selector(pickerDidSelectFontColor:)]) 219 | [self.delegate pickerDidSelectFontColor:[self selectedColor]]; 220 | 221 | _color = [self selectedColor]; 222 | } 223 | 224 | if ([self.delegate respondsToSelector:@selector(pickerDidSelectFont:withSize:color:)]) 225 | [self.delegate pickerDidSelectFont:_fontName withSize:_fontSize color:_color]; 226 | } 227 | 228 | #pragma mark - Font name component data 229 | - (NSArray *)fontList 230 | { 231 | if (_fontList.count) { 232 | return _fontList; 233 | } 234 | 235 | // list all font names in system 236 | NSArray *fonts = [[NSMutableArray alloc] init]; 237 | NSArray *families = [UIFont familyNames]; 238 | for (NSString *familyName in families) { 239 | NSArray *names = [UIFont fontNamesForFamilyName:familyName]; 240 | 241 | fonts = [fonts arrayByAddingObjectsFromArray:names]; 242 | } 243 | 244 | // add current font name when not found in list 245 | if (_fontName) { 246 | _fontList = fonts; 247 | NSInteger index = [self indexForFontName:_fontName]; 248 | if (index == NSNotFound) { 249 | NSArray *temp = @[ _fontName ]; 250 | fonts = [temp arrayByAddingObjectsFromArray:fonts]; 251 | } 252 | } 253 | 254 | // sort by font name 255 | fonts = [fonts sortedArrayUsingComparator:^NSComparisonResult(NSString *str1, NSString *str2) { 256 | return [str1 localizedCaseInsensitiveCompare:str2]; 257 | }]; 258 | 259 | _fontList = fonts; 260 | return _fontList; 261 | } 262 | 263 | - (NSInteger)indexForFontName:(NSString *)fontName 264 | { 265 | for (int i = 0; i < self.fontList.count; i++) { 266 | NSString *testName = self.fontList[i]; 267 | if ([fontName isEqualToString:testName]) { 268 | return i; 269 | } 270 | } 271 | if ([fontName hasPrefix:@"."]) { 272 | fontName = [fontName substringFromIndex:1]; 273 | return [self indexForFontName:fontName]; 274 | } 275 | return NSNotFound; 276 | } 277 | 278 | #pragma mark - Font size component data 279 | - (NSArray *)sizeList 280 | { 281 | // if (self.sizeHidden) { 282 | // return @[]; 283 | // } 284 | if (_sizeList.count) { 285 | return _sizeList; 286 | } 287 | 288 | if (!(self.minFontSize > 0)) { 289 | self.minFontSize = KPFontPickerMinFontSizeDefault; 290 | } 291 | if (!(self.maxFontSize > 0)) { 292 | self.maxFontSize = KPFontPickerMaxFontSizeDefault; 293 | } 294 | if (!(self.stepFontSize > 0)) { 295 | self.stepFontSize = KpFontPickerStepFontSizeDefault; 296 | } 297 | 298 | NSMutableArray *sizes = [[NSMutableArray alloc] init]; 299 | for (CGFloat fsize = self.minFontSize; fsize <= self.maxFontSize; fsize += self.stepFontSize) { 300 | NSNumber *nsize = [NSNumber numberWithFloat:fsize]; 301 | [sizes addObject:nsize]; 302 | } 303 | 304 | // add current font size when not found in list 305 | if (_fontSize) { 306 | _sizeList = sizes; 307 | NSInteger index = [self indexForFontSize:_fontSize]; 308 | if (index == NSNotFound) { 309 | NSNumber *nsize = [NSNumber numberWithFloat:_fontSize]; 310 | [sizes addObject:nsize]; 311 | 312 | // sort by font name 313 | NSArray *temp = [sizes sortedArrayUsingComparator:^NSComparisonResult(NSNumber *size1, NSNumber *size2) { 314 | return [size1 compare:size2]; 315 | }]; 316 | sizes = [NSMutableArray arrayWithArray:temp]; 317 | } 318 | } 319 | 320 | _sizeList = [NSArray arrayWithArray:sizes]; 321 | return _sizeList; 322 | } 323 | 324 | - (NSInteger)indexForFontSize:(CGFloat)pointSize 325 | { 326 | for (int i = 0; i < self.sizeList.count; i++) { 327 | NSNumber *fontNumber = self.sizeList[i]; 328 | CGFloat fontSize = fontNumber.floatValue; 329 | if (fontSize == pointSize) { 330 | return i; 331 | } 332 | } 333 | return NSNotFound; 334 | } 335 | 336 | - (CGFloat)selectedFontSize 337 | { 338 | CGFloat fontSize = self.minFontSize; 339 | 340 | NSInteger sizeIndex = [_pickerView selectedRowInComponent:1]; 341 | if (sizeIndex > -1) { 342 | NSNumber *sizeNumber = self.sizeList[sizeIndex]; 343 | fontSize = sizeNumber.floatValue; 344 | } 345 | 346 | return fontSize; 347 | } 348 | 349 | - (NSString *)selectedFontName 350 | { 351 | NSString *fontName; 352 | NSInteger fontIndex = [_pickerView selectedRowInComponent:0]; 353 | if (fontIndex > -1) { 354 | fontName = self.fontList[fontIndex]; 355 | } 356 | return fontName; 357 | } 358 | 359 | #pragma mark - Font color component data 360 | - (NSArray *)colorList 361 | { 362 | if (_colorList.count) { 363 | return _colorList; 364 | } 365 | NSMutableArray *colors = [[NSMutableArray alloc] init]; 366 | 367 | // default variants 368 | if (!(self.colorVariants < 0)) { 369 | self.colorVariants = KPFontPickerColorVariantsDefault; 370 | } 371 | if (!(self.grayVariants < 0)) { 372 | self.grayVariants = KPFontPickerGrayVariantsDefault; 373 | } 374 | 375 | // add color variants 376 | if (self.colorVariants > 0) { 377 | int ilevel = (int)ceil(pow((double)self.colorVariants, 1.0 / 3.0)); 378 | CGFloat flevel = (float)ilevel - 1; 379 | for (int r = 0; r < ilevel; r++) { 380 | for (int g = 0; g < ilevel; g++) { 381 | for (int b = ilevel - 1; b >= 0; b--) { 382 | if (colors.count >= self.colorVariants) 383 | break; 384 | if (self.grayVariants > 0 && r == g && g == b) 385 | continue; 386 | UIColor *color = [UIColor colorWithRed:r / flevel green:g / flevel blue:b / flevel alpha:1.0]; 387 | [colors addObject:color]; 388 | } 389 | } 390 | } 391 | } 392 | 393 | // add grayscale variants 394 | if (self.grayVariants > 0) { 395 | NSInteger ilevel = self.grayVariants; 396 | CGFloat flevel = (float)ilevel - 1; 397 | for (int w = 0; w < ilevel; w++) { 398 | UIColor *color = [UIColor colorWithRed:w / flevel green:w / flevel blue:w / flevel alpha:1.0]; 399 | [colors addObject:color]; 400 | } 401 | } 402 | 403 | // add current color when not found in list 404 | if (_color) { 405 | _colorList = colors; 406 | NSInteger index = [self indexForColor:_color]; 407 | if (index == NSNotFound) { 408 | NSArray *temp = @[ _color ]; 409 | temp = [temp arrayByAddingObjectsFromArray:colors]; 410 | colors = [NSMutableArray arrayWithArray:temp]; 411 | } 412 | } 413 | 414 | // sort by H/B/S 415 | NSArray *sorted = [colors sortedArrayUsingComparator:^NSComparisonResult(UIColor *col1, UIColor *col2) { 416 | CGFloat h1, s1, b1, a1; 417 | [col1 getHue:&h1 saturation:&s1 brightness:&b1 alpha:&a1]; 418 | 419 | CGFloat h2, s2, b2, a2; 420 | [col2 getHue:&h2 saturation:&s2 brightness:&b2 alpha:&a2]; 421 | 422 | if (h1 > h2) { 423 | return NSOrderedAscending; 424 | } else if (h1 < h2) { 425 | return NSOrderedDescending; 426 | } 427 | if (b1 > b2) { 428 | return NSOrderedAscending; 429 | } else if (b1 < b2) { 430 | return NSOrderedDescending; 431 | } 432 | if (s1 > s2) { 433 | return NSOrderedAscending; 434 | } else if (s1 < s2) { 435 | return NSOrderedDescending; 436 | } 437 | return NSOrderedSame; 438 | }]; 439 | 440 | _colorList = sorted; 441 | return _colorList; 442 | } 443 | 444 | - (NSInteger)indexForColor:(UIColor *)color 445 | { 446 | if (!color) 447 | return NSNotFound; 448 | CGFloat r1, g1, b1, a1; 449 | [color getRed:&r1 green:&g1 blue:&b1 alpha:&a1]; 450 | r1 = round(r1 * 255); 451 | g1 = round(g1 * 255); 452 | b1 = round(b1 * 255); 453 | 454 | for (int i = 0; i < self.colorList.count; i++) { 455 | UIColor *testColor = self.colorList[i]; 456 | if (!testColor) 457 | return NSNotFound; 458 | CGFloat r2, g2, b2, a2; 459 | [testColor getRed:&r2 green:&g2 blue:&b2 alpha:&a2]; 460 | r2 = round(r2 * 255); 461 | g2 = round(g2 * 255); 462 | b2 = round(b2 * 255); 463 | 464 | // test RGB color code as 0-255 integer number but not float number 465 | if (r1 == r2 && g1 == g2 && b1 == b2) { 466 | return i; 467 | } 468 | } 469 | return NSNotFound; 470 | } 471 | 472 | - (UIColor *)selectedColor 473 | { 474 | NSInteger colorIndex; 475 | UIColor *color; 476 | colorIndex = [_pickerView selectedRowInComponent:2]; 477 | if (colorIndex > -1) { 478 | color = self.colorList[colorIndex]; 479 | } 480 | return color; 481 | } 482 | 483 | @end 484 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kirill Pahnev 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 | -------------------------------------------------------------------------------- /README images/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pahnev/KPFontPicker/160461aaf3cfe13dd24f889f9f1f92514177e215/README images/demo.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/pahnev/KPFontPicker.svg?branch=master)](https://travis-ci.org/pahnev/KPFontPicker) 2 | 3 | # KPFontPicker 4 | Simple container view for a `UIPicker`. 5 | 6 | ![Demo](https://raw.github.com/pahnev/KPFontPicker/master/README%20images/demo.gif) 7 | 8 | 9 | # How to use 10 | Just add KPFontPicker into your project and implement delegate method. 11 | 12 | ```objc 13 | - (void)pickerDidSelectFont:(NSString *)font withSize:(CGFloat)fontSize color:(UIColor *)fontColor 14 | ``` 15 | Check demo for details 16 | 17 | # Todo 18 | - Landscape support 19 | - iPad support? 20 | 21 | # Licence 22 | This project is released under MIT License. Feel free to fork and stuff. --------------------------------------------------------------------------------