├── .DS_Store ├── IconFont_Demo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── geek.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── geek.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── IconFont_Demo.xcscheme │ └── xcschememanagement.plist ├── IconFont_Demo ├── .DS_Store ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── IconFontLib │ ├── LBPFontInfo.h │ ├── LBPFontInfo.m │ ├── LBPIconFont.h │ ├── LBPIconFont.m │ ├── UIColor+picker.h │ ├── UIColor+picker.m │ ├── UIImage+LBPIconFont.h │ └── UIImage+LBPIconFont.m ├── Info.plist ├── ViewController.h ├── ViewController.m ├── iconfont.ttf └── main.m └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FantasticLBP/IconFont_Demo/a9d97067c6537ff82e344908bb29e352bb60676a/.DS_Store -------------------------------------------------------------------------------- /IconFont_Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 933B2BF61ED7F72A00C94C7B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 933B2BF51ED7F72A00C94C7B /* main.m */; }; 11 | 933B2BF91ED7F72A00C94C7B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 933B2BF81ED7F72A00C94C7B /* AppDelegate.m */; }; 12 | 933B2BFC1ED7F72A00C94C7B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 933B2BFB1ED7F72A00C94C7B /* ViewController.m */; }; 13 | 933B2BFF1ED7F72A00C94C7B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 933B2BFD1ED7F72A00C94C7B /* Main.storyboard */; }; 14 | 933B2C011ED7F72A00C94C7B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 933B2C001ED7F72A00C94C7B /* Assets.xcassets */; }; 15 | 933B2C041ED7F72A00C94C7B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 933B2C021ED7F72A00C94C7B /* LaunchScreen.storyboard */; }; 16 | 933B2C0C1ED7F77200C94C7B /* iconfont.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 933B2C0B1ED7F74C00C94C7B /* iconfont.ttf */; }; 17 | 93D4A4411EDA966900467A3B /* LBPFontInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D4A4401EDA966900467A3B /* LBPFontInfo.m */; }; 18 | 93D4A4441EDA981F00467A3B /* UIColor+picker.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D4A4431EDA981F00467A3B /* UIColor+picker.m */; }; 19 | 93D4A4471EDA9A5000467A3B /* LBPIconFont.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D4A4461EDA9A5000467A3B /* LBPIconFont.m */; }; 20 | 93D4A44A1EDAA21400467A3B /* UIImage+LBPIconFont.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D4A4491EDAA21400467A3B /* UIImage+LBPIconFont.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 933B2BF11ED7F72A00C94C7B /* IconFont_Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IconFont_Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 933B2BF51ED7F72A00C94C7B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 26 | 933B2BF71ED7F72A00C94C7B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 27 | 933B2BF81ED7F72A00C94C7B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 28 | 933B2BFA1ED7F72A00C94C7B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 29 | 933B2BFB1ED7F72A00C94C7B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 30 | 933B2BFE1ED7F72A00C94C7B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 31 | 933B2C001ED7F72A00C94C7B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 32 | 933B2C031ED7F72A00C94C7B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 33 | 933B2C051ED7F72A00C94C7B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 933B2C0B1ED7F74C00C94C7B /* iconfont.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = iconfont.ttf; sourceTree = ""; }; 35 | 93D4A43F1EDA966900467A3B /* LBPFontInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LBPFontInfo.h; sourceTree = ""; }; 36 | 93D4A4401EDA966900467A3B /* LBPFontInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LBPFontInfo.m; sourceTree = ""; }; 37 | 93D4A4421EDA981F00467A3B /* UIColor+picker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+picker.h"; sourceTree = ""; }; 38 | 93D4A4431EDA981F00467A3B /* UIColor+picker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+picker.m"; sourceTree = ""; }; 39 | 93D4A4451EDA9A5000467A3B /* LBPIconFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LBPIconFont.h; sourceTree = ""; }; 40 | 93D4A4461EDA9A5000467A3B /* LBPIconFont.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LBPIconFont.m; sourceTree = ""; }; 41 | 93D4A4481EDAA21400467A3B /* UIImage+LBPIconFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+LBPIconFont.h"; sourceTree = ""; }; 42 | 93D4A4491EDAA21400467A3B /* UIImage+LBPIconFont.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+LBPIconFont.m"; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | 933B2BEE1ED7F72A00C94C7B /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | ); 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | /* End PBXFrameworksBuildPhase section */ 54 | 55 | /* Begin PBXGroup section */ 56 | 933B2BE81ED7F72A00C94C7B = { 57 | isa = PBXGroup; 58 | children = ( 59 | 933B2BF31ED7F72A00C94C7B /* IconFont_Demo */, 60 | 933B2BF21ED7F72A00C94C7B /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | 933B2BF21ED7F72A00C94C7B /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 933B2BF11ED7F72A00C94C7B /* IconFont_Demo.app */, 68 | ); 69 | name = Products; 70 | sourceTree = ""; 71 | }; 72 | 933B2BF31ED7F72A00C94C7B /* IconFont_Demo */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 93D4A43E1EDA95EB00467A3B /* IconFontLib */, 76 | 933B2BF71ED7F72A00C94C7B /* AppDelegate.h */, 77 | 933B2BF81ED7F72A00C94C7B /* AppDelegate.m */, 78 | 933B2BFA1ED7F72A00C94C7B /* ViewController.h */, 79 | 933B2BFB1ED7F72A00C94C7B /* ViewController.m */, 80 | 933B2BF41ED7F72A00C94C7B /* Supporting Files */, 81 | ); 82 | path = IconFont_Demo; 83 | sourceTree = ""; 84 | }; 85 | 933B2BF41ED7F72A00C94C7B /* Supporting Files */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 933B2C0B1ED7F74C00C94C7B /* iconfont.ttf */, 89 | 933B2BFD1ED7F72A00C94C7B /* Main.storyboard */, 90 | 933B2C001ED7F72A00C94C7B /* Assets.xcassets */, 91 | 933B2C021ED7F72A00C94C7B /* LaunchScreen.storyboard */, 92 | 933B2C051ED7F72A00C94C7B /* Info.plist */, 93 | 933B2BF51ED7F72A00C94C7B /* main.m */, 94 | ); 95 | name = "Supporting Files"; 96 | sourceTree = ""; 97 | }; 98 | 93D4A43E1EDA95EB00467A3B /* IconFontLib */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 93D4A43F1EDA966900467A3B /* LBPFontInfo.h */, 102 | 93D4A4401EDA966900467A3B /* LBPFontInfo.m */, 103 | 93D4A4421EDA981F00467A3B /* UIColor+picker.h */, 104 | 93D4A4431EDA981F00467A3B /* UIColor+picker.m */, 105 | 93D4A4451EDA9A5000467A3B /* LBPIconFont.h */, 106 | 93D4A4461EDA9A5000467A3B /* LBPIconFont.m */, 107 | 93D4A4481EDAA21400467A3B /* UIImage+LBPIconFont.h */, 108 | 93D4A4491EDAA21400467A3B /* UIImage+LBPIconFont.m */, 109 | ); 110 | path = IconFontLib; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | 933B2BF01ED7F72A00C94C7B /* IconFont_Demo */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = 933B2C081ED7F72A00C94C7B /* Build configuration list for PBXNativeTarget "IconFont_Demo" */; 119 | buildPhases = ( 120 | 933B2BED1ED7F72A00C94C7B /* Sources */, 121 | 933B2BEE1ED7F72A00C94C7B /* Frameworks */, 122 | 933B2BEF1ED7F72A00C94C7B /* Resources */, 123 | ); 124 | buildRules = ( 125 | ); 126 | dependencies = ( 127 | ); 128 | name = IconFont_Demo; 129 | productName = IconFont_Demo; 130 | productReference = 933B2BF11ED7F72A00C94C7B /* IconFont_Demo.app */; 131 | productType = "com.apple.product-type.application"; 132 | }; 133 | /* End PBXNativeTarget section */ 134 | 135 | /* Begin PBXProject section */ 136 | 933B2BE91ED7F72A00C94C7B /* Project object */ = { 137 | isa = PBXProject; 138 | attributes = { 139 | LastUpgradeCheck = 0830; 140 | ORGANIZATIONNAME = Liubp; 141 | TargetAttributes = { 142 | 933B2BF01ED7F72A00C94C7B = { 143 | CreatedOnToolsVersion = 8.3.2; 144 | ProvisioningStyle = Automatic; 145 | }; 146 | }; 147 | }; 148 | buildConfigurationList = 933B2BEC1ED7F72A00C94C7B /* Build configuration list for PBXProject "IconFont_Demo" */; 149 | compatibilityVersion = "Xcode 3.2"; 150 | developmentRegion = English; 151 | hasScannedForEncodings = 0; 152 | knownRegions = ( 153 | en, 154 | Base, 155 | ); 156 | mainGroup = 933B2BE81ED7F72A00C94C7B; 157 | productRefGroup = 933B2BF21ED7F72A00C94C7B /* Products */; 158 | projectDirPath = ""; 159 | projectRoot = ""; 160 | targets = ( 161 | 933B2BF01ED7F72A00C94C7B /* IconFont_Demo */, 162 | ); 163 | }; 164 | /* End PBXProject section */ 165 | 166 | /* Begin PBXResourcesBuildPhase section */ 167 | 933B2BEF1ED7F72A00C94C7B /* Resources */ = { 168 | isa = PBXResourcesBuildPhase; 169 | buildActionMask = 2147483647; 170 | files = ( 171 | 933B2C0C1ED7F77200C94C7B /* iconfont.ttf in Resources */, 172 | 933B2C041ED7F72A00C94C7B /* LaunchScreen.storyboard in Resources */, 173 | 933B2C011ED7F72A00C94C7B /* Assets.xcassets in Resources */, 174 | 933B2BFF1ED7F72A00C94C7B /* Main.storyboard in Resources */, 175 | ); 176 | runOnlyForDeploymentPostprocessing = 0; 177 | }; 178 | /* End PBXResourcesBuildPhase section */ 179 | 180 | /* Begin PBXSourcesBuildPhase section */ 181 | 933B2BED1ED7F72A00C94C7B /* Sources */ = { 182 | isa = PBXSourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | 933B2BFC1ED7F72A00C94C7B /* ViewController.m in Sources */, 186 | 93D4A4411EDA966900467A3B /* LBPFontInfo.m in Sources */, 187 | 93D4A4471EDA9A5000467A3B /* LBPIconFont.m in Sources */, 188 | 933B2BF91ED7F72A00C94C7B /* AppDelegate.m in Sources */, 189 | 93D4A4441EDA981F00467A3B /* UIColor+picker.m in Sources */, 190 | 933B2BF61ED7F72A00C94C7B /* main.m in Sources */, 191 | 93D4A44A1EDAA21400467A3B /* UIImage+LBPIconFont.m in Sources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXSourcesBuildPhase section */ 196 | 197 | /* Begin PBXVariantGroup section */ 198 | 933B2BFD1ED7F72A00C94C7B /* Main.storyboard */ = { 199 | isa = PBXVariantGroup; 200 | children = ( 201 | 933B2BFE1ED7F72A00C94C7B /* Base */, 202 | ); 203 | name = Main.storyboard; 204 | sourceTree = ""; 205 | }; 206 | 933B2C021ED7F72A00C94C7B /* LaunchScreen.storyboard */ = { 207 | isa = PBXVariantGroup; 208 | children = ( 209 | 933B2C031ED7F72A00C94C7B /* Base */, 210 | ); 211 | name = LaunchScreen.storyboard; 212 | sourceTree = ""; 213 | }; 214 | /* End PBXVariantGroup section */ 215 | 216 | /* Begin XCBuildConfiguration section */ 217 | 933B2C061ED7F72A00C94C7B /* Debug */ = { 218 | isa = XCBuildConfiguration; 219 | buildSettings = { 220 | ALWAYS_SEARCH_USER_PATHS = NO; 221 | CLANG_ANALYZER_NONNULL = YES; 222 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 223 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 224 | CLANG_CXX_LIBRARY = "libc++"; 225 | CLANG_ENABLE_MODULES = YES; 226 | CLANG_ENABLE_OBJC_ARC = YES; 227 | CLANG_WARN_BOOL_CONVERSION = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 230 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 231 | CLANG_WARN_EMPTY_BODY = YES; 232 | CLANG_WARN_ENUM_CONVERSION = YES; 233 | CLANG_WARN_INFINITE_RECURSION = YES; 234 | CLANG_WARN_INT_CONVERSION = YES; 235 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 236 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 237 | CLANG_WARN_UNREACHABLE_CODE = YES; 238 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 239 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 240 | COPY_PHASE_STRIP = NO; 241 | DEBUG_INFORMATION_FORMAT = dwarf; 242 | ENABLE_STRICT_OBJC_MSGSEND = YES; 243 | ENABLE_TESTABILITY = YES; 244 | GCC_C_LANGUAGE_STANDARD = gnu99; 245 | GCC_DYNAMIC_NO_PIC = NO; 246 | GCC_NO_COMMON_BLOCKS = YES; 247 | GCC_OPTIMIZATION_LEVEL = 0; 248 | GCC_PREPROCESSOR_DEFINITIONS = ( 249 | "DEBUG=1", 250 | "$(inherited)", 251 | ); 252 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 253 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 254 | GCC_WARN_UNDECLARED_SELECTOR = YES; 255 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 256 | GCC_WARN_UNUSED_FUNCTION = YES; 257 | GCC_WARN_UNUSED_VARIABLE = YES; 258 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 259 | MTL_ENABLE_DEBUG_INFO = YES; 260 | ONLY_ACTIVE_ARCH = YES; 261 | SDKROOT = iphoneos; 262 | }; 263 | name = Debug; 264 | }; 265 | 933B2C071ED7F72A00C94C7B /* Release */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | ALWAYS_SEARCH_USER_PATHS = NO; 269 | CLANG_ANALYZER_NONNULL = YES; 270 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 271 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 272 | CLANG_CXX_LIBRARY = "libc++"; 273 | CLANG_ENABLE_MODULES = YES; 274 | CLANG_ENABLE_OBJC_ARC = YES; 275 | CLANG_WARN_BOOL_CONVERSION = YES; 276 | CLANG_WARN_CONSTANT_CONVERSION = YES; 277 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 278 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 279 | CLANG_WARN_EMPTY_BODY = YES; 280 | CLANG_WARN_ENUM_CONVERSION = YES; 281 | CLANG_WARN_INFINITE_RECURSION = YES; 282 | CLANG_WARN_INT_CONVERSION = YES; 283 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 284 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 285 | CLANG_WARN_UNREACHABLE_CODE = YES; 286 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 287 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 288 | COPY_PHASE_STRIP = NO; 289 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 290 | ENABLE_NS_ASSERTIONS = NO; 291 | ENABLE_STRICT_OBJC_MSGSEND = YES; 292 | GCC_C_LANGUAGE_STANDARD = gnu99; 293 | GCC_NO_COMMON_BLOCKS = YES; 294 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 295 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 296 | GCC_WARN_UNDECLARED_SELECTOR = YES; 297 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 298 | GCC_WARN_UNUSED_FUNCTION = YES; 299 | GCC_WARN_UNUSED_VARIABLE = YES; 300 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 301 | MTL_ENABLE_DEBUG_INFO = NO; 302 | SDKROOT = iphoneos; 303 | VALIDATE_PRODUCT = YES; 304 | }; 305 | name = Release; 306 | }; 307 | 933B2C091ED7F72A00C94C7B /* Debug */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 311 | INFOPLIST_FILE = IconFont_Demo/Info.plist; 312 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 313 | PRODUCT_BUNDLE_IDENTIFIER = "com.geek.IconFont-Demo"; 314 | PRODUCT_NAME = "$(TARGET_NAME)"; 315 | }; 316 | name = Debug; 317 | }; 318 | 933B2C0A1ED7F72A00C94C7B /* Release */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 322 | INFOPLIST_FILE = IconFont_Demo/Info.plist; 323 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 324 | PRODUCT_BUNDLE_IDENTIFIER = "com.geek.IconFont-Demo"; 325 | PRODUCT_NAME = "$(TARGET_NAME)"; 326 | }; 327 | name = Release; 328 | }; 329 | /* End XCBuildConfiguration section */ 330 | 331 | /* Begin XCConfigurationList section */ 332 | 933B2BEC1ED7F72A00C94C7B /* Build configuration list for PBXProject "IconFont_Demo" */ = { 333 | isa = XCConfigurationList; 334 | buildConfigurations = ( 335 | 933B2C061ED7F72A00C94C7B /* Debug */, 336 | 933B2C071ED7F72A00C94C7B /* Release */, 337 | ); 338 | defaultConfigurationIsVisible = 0; 339 | defaultConfigurationName = Release; 340 | }; 341 | 933B2C081ED7F72A00C94C7B /* Build configuration list for PBXNativeTarget "IconFont_Demo" */ = { 342 | isa = XCConfigurationList; 343 | buildConfigurations = ( 344 | 933B2C091ED7F72A00C94C7B /* Debug */, 345 | 933B2C0A1ED7F72A00C94C7B /* Release */, 346 | ); 347 | defaultConfigurationIsVisible = 0; 348 | defaultConfigurationName = Release; 349 | }; 350 | /* End XCConfigurationList section */ 351 | }; 352 | rootObject = 933B2BE91ED7F72A00C94C7B /* Project object */; 353 | } 354 | -------------------------------------------------------------------------------- /IconFont_Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /IconFont_Demo.xcodeproj/project.xcworkspace/xcuserdata/geek.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FantasticLBP/IconFont_Demo/a9d97067c6537ff82e344908bb29e352bb60676a/IconFont_Demo.xcodeproj/project.xcworkspace/xcuserdata/geek.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /IconFont_Demo.xcodeproj/xcuserdata/geek.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /IconFont_Demo.xcodeproj/xcuserdata/geek.xcuserdatad/xcschemes/IconFont_Demo.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 | -------------------------------------------------------------------------------- /IconFont_Demo.xcodeproj/xcuserdata/geek.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | IconFont_Demo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 933B2BF01ED7F72A00C94C7B 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /IconFont_Demo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FantasticLBP/IconFont_Demo/a9d97067c6537ff82e344908bb29e352bb60676a/IconFont_Demo/.DS_Store -------------------------------------------------------------------------------- /IconFont_Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // IconFont_Demo 4 | // 5 | // Created by geek on 2017/5/26. 6 | // Copyright © 2017年 Liubp. 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 | -------------------------------------------------------------------------------- /IconFont_Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // IconFont_Demo 4 | // 5 | // Created by geek on 2017/5/26. 6 | // Copyright © 2017年 Liubp. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "LBPIconFont.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | [LBPIconFont setFontName:@"iconfont"]; 21 | // Override point for customization after application launch. 22 | return YES; 23 | } 24 | 25 | 26 | - (void)applicationWillResignActive:(UIApplication *)application { 27 | // 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. 28 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 29 | } 30 | 31 | 32 | - (void)applicationDidEnterBackground:(UIApplication *)application { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | 38 | - (void)applicationWillEnterForeground:(UIApplication *)application { 39 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 40 | } 41 | 42 | 43 | - (void)applicationDidBecomeActive:(UIApplication *)application { 44 | // 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. 45 | } 46 | 47 | 48 | - (void)applicationWillTerminate:(UIApplication *)application { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /IconFont_Demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /IconFont_Demo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /IconFont_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 | -------------------------------------------------------------------------------- /IconFont_Demo/IconFontLib/LBPFontInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // LBPFontInfo.h 3 | // IconFont_Demo 4 | // 5 | // Created by geek on 2017/5/28. 6 | // Copyright © 2017年 Liubp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface LBPFontInfo : NSObject 13 | 14 | @property (nonatomic, strong) NSString *text; /**<图标对应的unicode码*/ 15 | 16 | @property (nonatomic, assign) NSInteger size; /**<尺寸大小*/ 17 | 18 | @property (nonatomic, strong) UIColor *color; /**<颜色信息*/ 19 | 20 | /** 21 | * 对象方法(实例方法)返回一个IconFont信息对象 22 | * 23 | * @param text 图标对应的unicode码 24 | * 25 | * @param size 尺寸大小 26 | * 27 | * @param color 颜色信息 28 | * 29 | * @return LBPFontInfo对象 30 | */ 31 | 32 | -(instancetype)initWithText:(NSString *)text withSize:(NSInteger)size andColor:(NSString *)color; 33 | 34 | 35 | /** 36 | * 类方法返回一个IconFont信息对象 37 | * 38 | * @param text 图标对应的unicode码 39 | * 40 | * @param size 尺寸大小 41 | * 42 | * @param color 颜色信息 43 | * 44 | * @return LBPFontInfo对象 45 | */ 46 | +(instancetype)LBPFontInfoWithText:(NSString *)text withSize:(NSInteger)size andColor:(NSString *)color; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /IconFont_Demo/IconFontLib/LBPFontInfo.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // LBPFontInfo.m 4 | // IconFont_Demo 5 | // 6 | // Created by geek on 2017/5/28. 7 | // Copyright © 2017年 Liubp. All rights reserved. 8 | // 9 | 10 | #import "LBPFontInfo.h" 11 | #import "UIColor+picker.h" 12 | 13 | @implementation LBPFontInfo 14 | 15 | -(instancetype)initWithText:(NSString *)text withSize:(NSInteger)size andColor:(NSString *)color{ 16 | if (self = [super init]) { 17 | self.text = text; 18 | self.color = [UIColor colorWithHexString:color]; 19 | self.size = size; 20 | } 21 | return self; 22 | } 23 | 24 | 25 | +(instancetype)LBPFontInfoWithText:(NSString *)text withSize:(NSInteger)size andColor:(NSString *)color{ 26 | return [[LBPFontInfo alloc] initWithText:text withSize:size andColor:color]; 27 | } 28 | 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /IconFont_Demo/IconFontLib/LBPIconFont.h: -------------------------------------------------------------------------------- 1 | // 2 | // LBPIconFont.h 3 | // IconFont_Demo 4 | // 5 | // Created by geek on 2017/5/28. 6 | // Copyright © 2017年 Liubp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "LBPFontInfo.h" 11 | 12 | #define LBPIconFontmake(text,size,color) [[LBPFontInfo alloc] initWithText:text withSize:size andColor:color] 13 | 14 | @interface LBPIconFont : NSObject 15 | 16 | /** 17 | * 类方法 设置字体图标的大小 18 | * 19 | * @param size 图标对应的unicode码 20 | * 21 | * @return UIFont 22 | */ 23 | + (UIFont *)fontWithSize: (CGFloat)size; 24 | 25 | 26 | + (void)setFontName:(NSString *)fontName; 27 | 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /IconFont_Demo/IconFontLib/LBPIconFont.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | // 4 | // LBPIconFont.m 5 | // IconFont_Demo 6 | // 7 | // Created by geek on 2017/5/28. 8 | // Copyright © 2017年 Liubp. All rights reserved. 9 | // 10 | 11 | #import "LBPIconFont.h" 12 | #import 13 | 14 | static NSString *_fontName; 15 | 16 | @implementation LBPIconFont 17 | 18 | +(void)registerFontWithFontUrl:(NSURL *)url{ 19 | NSAssert([[NSFileManager defaultManager] fileExistsAtPath:[url path]], @"Font file doesn't exist"); 20 | CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL((__bridge CFURLRef)url); 21 | CGFontRef newFont = CGFontCreateWithDataProvider(fontDataProvider); 22 | CGDataProviderRelease(fontDataProvider); 23 | CTFontManagerRegisterGraphicsFont(newFont, nil); 24 | CGFontRelease(newFont); 25 | 26 | } 27 | 28 | + (UIFont *)fontWithSize: (CGFloat)size{ 29 | UIFont *font = [UIFont fontWithName:[self fontName] size:size]; 30 | if (font == nil) { 31 | NSURL *fontFileUrl = [[NSBundle mainBundle] URLForResource:[self fontName] withExtension:@"ttf"]; 32 | [self registerFontWithFontUrl:fontFileUrl]; 33 | font = [UIFont fontWithName:[self fontName] size:size]; 34 | NSAssert(font, @"UIFont object should not be nil, check if the font file is added to the application bundle and you're using the correct font name."); 35 | } 36 | return font; 37 | } 38 | 39 | 40 | + (void)setFontName:(NSString *)fontName{ 41 | _fontName = fontName; 42 | } 43 | 44 | 45 | +(NSString *)fontName{ 46 | return _fontName; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /IconFont_Demo/IconFontLib/UIColor+picker.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+picker.h 3 | // IconFont_Demo 4 | // 5 | // Created by geek on 2017/5/28. 6 | // Copyright © 2017年 Liubp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (picker) 12 | 13 | /** 14 | * 颜色转换:iOS中(以#开头)十六进制的颜色转换为UIColor(RGB) 15 | * 16 | * @param color 颜色的十六进制值 17 | * 18 | * @return UIColor 19 | */ 20 | 21 | + (UIColor *) colorWithHexString: (NSString *)color; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /IconFont_Demo/IconFontLib/UIColor+picker.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+picker.m 3 | // IconFont_Demo 4 | // 5 | // Created by geek on 2017/5/28. 6 | // Copyright © 2017年 Liubp. All rights reserved. 7 | // 8 | 9 | #import "UIColor+picker.h" 10 | 11 | @implementation UIColor (picker) 12 | 13 | 14 | + (UIColor *) colorWithHexString: (NSString *)color{ 15 | NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; 16 | 17 | // String should be 6 or 8 characters 18 | if ([cString length] < 6) { 19 | return [UIColor clearColor]; 20 | } 21 | // 判断前缀 22 | if ([cString hasPrefix:@"0X"]) 23 | cString = [cString substringFromIndex:2]; 24 | if ([cString hasPrefix:@"#"]) 25 | cString = [cString substringFromIndex:1]; 26 | if ([cString length] != 6) 27 | return [UIColor clearColor]; 28 | // 从六位数值中找到RGB对应的位数并转换 29 | NSRange range; 30 | range.location = 0; 31 | range.length = 2; 32 | //R、G、B 33 | NSString *rString = [cString substringWithRange:range]; 34 | range.location = 2; 35 | NSString *gString = [cString substringWithRange:range]; 36 | range.location = 4; 37 | NSString *bString = [cString substringWithRange:range]; 38 | // Scan values 39 | unsigned int r, g, b; 40 | [[NSScanner scannerWithString:rString] scanHexInt:&r]; 41 | [[NSScanner scannerWithString:gString] scanHexInt:&g]; 42 | [[NSScanner scannerWithString:bString] scanHexInt:&b]; 43 | 44 | return [UIColor colorWithRed:((float) r / 255.0f) green:((float) g / 255.0f) blue:((float) b / 255.0f) alpha:1.0f]; 45 | } 46 | 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /IconFont_Demo/IconFontLib/UIImage+LBPIconFont.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+LBPIconFont.h 3 | // IconFont_Demo 4 | // 5 | // Created by geek on 2017/5/28. 6 | // Copyright © 2017年 Liubp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "LBPFontInfo.h" 11 | #import "LBPIconFont.h" 12 | 13 | @interface UIImage (LBPIconFont) 14 | 15 | + (UIImage *)iconWithInfo:(LBPFontInfo *)info; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /IconFont_Demo/IconFontLib/UIImage+LBPIconFont.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // UIImage+LBPIconFont.m 4 | // IconFont_Demo 5 | // 6 | // Created by geek on 2017/5/28. 7 | // Copyright © 2017年 Liubp. All rights reserved. 8 | // 9 | 10 | #import "UIImage+LBPIconFont.h" 11 | 12 | @implementation UIImage (LBPIconFont) 13 | 14 | 15 | + (UIImage *)iconWithInfo:(LBPFontInfo *)info{ 16 | CGFloat size = info.size; 17 | CGFloat scale = [UIScreen mainScreen].scale; 18 | CGFloat realSize = scale*size; 19 | 20 | UIFont *font = [LBPIconFont fontWithSize:realSize]; 21 | 22 | UIGraphicsBeginImageContext(CGSizeMake(realSize, realSize)); 23 | CGContextRef context = UIGraphicsGetCurrentContext(); 24 | 25 | if ([info.text respondsToSelector:@selector(drawAtPoint:withAttributes:)]) { 26 | /** 27 | * 如果这里抛出异常,请打开断点列表,右击All Exceptions -> Edit Breakpoint -> All修改为Objective-C 28 | * See: http://stackoverflow.com/questions/1163981/how-to-add-a-breakpoint-to-objc-exception-throw/14767076#14767076 29 | */ 30 | [info.text drawAtPoint:CGPointZero withAttributes:@{NSFontAttributeName:font, NSForegroundColorAttributeName: info.color}]; 31 | } else { 32 | 33 | #pragma clang diagnostic push 34 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" 35 | CGContextSetFillColorWithColor(context, info.color.CGColor); 36 | [info.text drawAtPoint:CGPointMake(0, 0) withFont:font]; 37 | #pragma clang pop 38 | } 39 | 40 | UIImage *image = [UIImage imageWithCGImage:UIGraphicsGetImageFromCurrentImageContext().CGImage scale:scale orientation:UIImageOrientationUp]; 41 | UIGraphicsEndImageContext(); 42 | 43 | return image; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /IconFont_Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | LSFileQuarantineEnabled 28 | 29 | UIAppFonts 30 | 31 | iconfont.ttf 32 | 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /IconFont_Demo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // IconFont_Demo 4 | // 5 | // Created by geek on 2017/5/26. 6 | // Copyright © 2017年 Liubp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /IconFont_Demo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // IconFont_Demo 4 | // 5 | // Created by geek on 2017/5/26. 6 | // Copyright © 2017年 Liubp. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "LBPIconFont.h" 11 | #import "UIImage+LBPIconFont.h" 12 | 13 | #define BoundWidth [[UIScreen mainScreen]bounds].size.width 14 | #define BoundHeight [[UIScreen mainScreen]bounds].size.height 15 | 16 | @interface ViewController () 17 | 18 | @property (nonatomic, strong) UILabel *labelUsageLabel; /**<文本形式使用iconfont标题*/ 19 | @property (nonatomic, strong) UILabel *imageUsageLabel; /**<图片形式使用iconfont标题*/ 20 | 21 | @property (nonatomic, strong) UILabel *label; /**<文字形式使用iconfont*/ 22 | @property (nonatomic, strong) UIImageView *imageView; /**<图片方式使用iconfont*/ 23 | @property (nonatomic, strong) UILabel *labelUsageButtonTitleLabel; 24 | /**<作为button的titlelabel使用*/ 25 | @property (nonatomic, strong) UIButton *button; /** 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 工程大小优化之图片资源 2 | 3 | > _摘要:_点点iOS项目本身功能较多,导致应用体积也比较大。一个Xcode工程下图片资源占用了很大的空间,且如果有些App需要一键换肤功能,呵呵,不知道得做多少图片。每套图片还需要设置1x@,2x@,3x@等 4 | 5 | ## 简介 6 | 7 | IconFont技术起源于Web领域的Web Font技术。随着时间的推移,网页设计越来越漂亮。但是电脑预装的字体远远无法满足设计者的要求,于是Web Font技术诞生了。一个英文字库并不大,通过网络下载字体,完成网页的显示。有了Web Font技术,大大提升了设计师的发挥空间。 8 | 9 | 网页设计中图标需要适配多个分辨率,每个图标需要占用一次网络请求。于是有人想到了用Web Font的方法来解决这两个问题,就是IconFont技术。将矢量的图标做成字体,一次网络请求就够了,可以保真缩放。解决这个问题的另一个方式是图片拼合的Sprite图。 10 | 11 | Web领域使用IconFont类似的技术已经多年,当我在15年接触BootStrap的时候Font Awesome技术大行其道。最近IconFont技术在iOS图片资源方面得以应用,最近有点时间自己研究整理了一番,在此记录学习点滴。 12 | 13 | ## 优点 14 | 15 | * 减小体积,字体文件比图片要小 16 | * 图标保真缩放,解决2x/3x乃至将来的nx图问题 17 | * 方便更改颜色大小,图片复用 18 | 19 | ## 缺点 20 | 21 | * 只适用于 22 | `纯色icon` 23 | * 使用unicode字符难以理解 24 | * 需要维护字体库 25 | 26 | 网上说了一大堆如何制作IconFont的方法,在此不做讨论。 27 | 28 | ## 我们说说怎么用 29 | 30 | 1. 首先选取一些有丰富资源的网站,我使用阿里的IconFont多年,其他的没去研究,所以此处直接使用阿里的产品。地址:[http://www.iconfont.cn/plus](http://www.iconfont.cn/plus) 31 | 2. 打开网站在线挑选好合适的图标加入购物车,如图![阿里IconFont](https://raw.githubusercontent.com/FantasticLBP/iOSKonwledge-Kit/master/assets/屏幕快照%202017-05-28%20下午2.43.33.png "阿里IconFont") 32 | 3. 选择好之后在购物车查看,然后点击下载代码![下载IconFont](https://raw.githubusercontent.com/FantasticLBP/iOSKonwledge-Kit/master/assets/屏幕快照%202017-05-28%20下午2.43.48.png "下载IconFont") 33 | 4. 打开下载好的文件,其机构如下,我们在iOS项目开发过程中使用unicode的形式使用IconFont,所以打开demo\_unicode.html 34 | ![下载文件目录结构](https://raw.githubusercontent.com/FantasticLBP/iOSKonwledge-Kit/master/assets/屏幕快照%202017-05-28%20下午2.44.09.png "下载文件目录结构") 35 | ![unicode形式使用IconFont](https://raw.githubusercontent.com/FantasticLBP/iOSKonwledge-Kit/master/assets/屏幕快照%202017-05-28%20下午2.44.22.png "unicode形式使用IconFont") 36 | 5. 注意:创建 UIFont 使用的是字体名,而不是文件名;文本值为 8 位的 Unicode 字符,我们可以打开 demo.html 查找每个图标所对应的 HTML 实体 Unicode 码,比如: "店" 对应的 HTML 实体 Unicode 码为:0x3439 转换后为:\U00003439 就是将 0x 替换为 \U 中间用 0 填补满长度为 8 个字符 37 | 38 | # Xcode中使用IconFont 39 | 40 | 初步尝试使用 41 | 42 | 1. 首先看看如何简单实用IconFont 43 | 2. 首先将下载好的文件夹中的**iconfont.ttf**加入到Xcode工程中,确保加入成功在Build检查![Xcode检查引入结果](https://raw.githubusercontent.com/FantasticLBP/iOSKonwledge-Kit/master/assets/屏幕快照%202017-05-28%20下午2.51.36.png "Xcode检查引入结果") 44 | 3. 怎么用? 45 | 46 | ``` 47 | NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:@"\U0000e696 \U0000e6ab \U0000e6ac \U0000e6ae"]; 48 | [attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)]; 49 | [attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(3, 1)]; 50 | [attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(9, 1)]; 51 | self.label.attributedText = attributedStr; 52 | 53 | [self.view addSubview:self.label]; 54 | 55 | pragma mark - getter and setter 56 | -(UILabel *)label{ 57 | if (!_label) { 58 | _label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, BoundWidth-200, 40)]; 59 | _label.font = [UIFont fontWithName:@"iconfont" size:24]; 60 | _label.textColor = [UIColor purpleColor]; 61 | } 62 | return _label; 63 | } 64 | ``` 65 | 66 | #### 做进一步封装,实用更加方便 67 | 68 |

利用IconFont生成1个UIImage只需要LBPIconFontmake(par1, par2, par3),par1:iconfont的unicode值;par2:图片大小;par3:图片的颜色值。

69 | 70 |

其中,LBPIconFontmake是一个宏,#define LBPIconFontmake(text,size,color) [[LBPFontInfo alloc] initWithText:text withSize:size andColor:color]。

71 | 72 | ``` 73 | self.latestImageView.image = [UIImage iconWithInfo:LBPIconFontmake(@"\U0000e6ac", 60, @"000066") ]; 74 | ``` 75 | 76 | 77 | 78 | ![封装后的工程目录结构](https://github.com/FantasticLBP/iOSKonwledge-Kit/raw/master/assets/屏幕快照%202017-05-28%20下午2.56.00.png "封装后的工程目录结构") 79 | 80 | 1. LBPFontInfo来封装字体信息 81 | 2. UIColor+picker根据十六进制字符串来设置颜色 82 | 3. LBPIconFont向系统中注册IconFont字体库,并使用 83 | 4. UIImage+LBPIconFont封装一个使用IconFont的Image分类 84 | 85 | # 效果图 86 | ![效果图](https://raw.githubusercontent.com/FantasticLBP/iOSKonwledge-Kit/master/assets/Simulator%20Screen%20Shot%202017年5月28日%20下午3.19.44.png "效果图") 87 | 88 | 89 | 90 | 如果有不懂的地方可以加入QQ交流群讨论:**515066271**。这个QQ群讨论技术范围包括:iOS、H5混合开发、前端开发、PHP开发,欢迎大家讨论技术。 91 | 92 | 93 | # Demo地址 94 | 95 | [https://github.com/FantasticLBP/IconFont\_Demo](https://github.com/FantasticLBP/IconFont_Demo) 96 | --------------------------------------------------------------------------------