├── HMObjcSugar ├── Assets.xcassets │ ├── Contents.json │ ├── Brand Assets.launchimage │ │ ├── Default.png │ │ ├── Default@2x-1.png │ │ ├── Default@2x.png │ │ ├── Default-568h@2x.png │ │ ├── Default-667h@2x.png │ │ ├── Default-736h@3x.png │ │ ├── Default-Landscape-736h@3x.png │ │ └── Contents.json │ ├── tabbar_compose_button.imageset │ │ ├── tabbar_compose_button@2x.png │ │ ├── tabbar_compose_button@3x.png │ │ └── Contents.json │ ├── tabbar_compose_icon_add.imageset │ │ ├── tabbar_compose_icon_add@2x.png │ │ ├── tabbar_compose_icon_add@3x.png │ │ └── Contents.json │ ├── tabbar_compose_button_highlighted.imageset │ │ ├── tabbar_compose_button_highlighted@2x.png │ │ ├── tabbar_compose_button_highlighted@3x.png │ │ └── Contents.json │ ├── tabbar_compose_icon_add_highlighted.imageset │ │ ├── tabbar_compose_icon_add_highlighted@2x.png │ │ ├── tabbar_compose_icon_add_highlighted@3x.png │ │ └── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── ViewController.h ├── AppDelegate.h ├── main.m ├── ObjcSugar │ ├── UIScreen+HMObjcSugar.h │ ├── NSBundle+HMObjcSugar.h │ ├── UINavigationController+HMObjcSugar.h │ ├── UIImage+HMObjcSugar.h │ ├── UITextField+HMObjcSugar.h │ ├── UIScreen+HMObjcSugar.m │ ├── UITextField+HMObjcSugar.m │ ├── HMObjcSugar.h │ ├── UIImage+HMObjcSugar.m │ ├── NSString+HMObjcSugar.h │ ├── UIView+HMObjcSugar.h │ ├── NSDate+HMObjcSugar.h │ ├── NSBundle+HMObjcSugar.m │ ├── UIColor+HMObjcSugar.h │ ├── NSString+HMObjcSugar.m │ ├── UILabel+HMObjcSugar.m │ ├── UIColor+HMObjcSugar.m │ ├── UILabel+HMObjcSugar.h │ ├── UIView+HMObjcSugar.m │ ├── NSDate+HMObjcSugar.m │ ├── UIButton+HMObjcSugar.h │ ├── UIButton+HMObjcSugar.m │ └── UINavigationController+HMObjcSugar.m ├── AppDelegate.m ├── Info.plist ├── ViewController.m └── Base.lproj │ └── Main.storyboard ├── HMObjcSugar.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcshareddata │ └── xcschemes │ │ ├── HMObjcSugarTests.xcscheme │ │ └── HMObjcSugar.xcscheme └── project.pbxproj ├── .travis.yml ├── HMObjcSugar.podspec ├── README.md ├── HMObjcSugarTests ├── TextFieldSugarTests.m ├── Info.plist ├── ScreenSugarTests.m ├── BundleSugarTests.m ├── ImageSugarTests.m ├── StringSugarTests.m ├── ColorSugarTests.m ├── DateSugarTests.m ├── LabelSugarTests.m ├── ViewSugarTests.m └── ButtonSugarTests.m ├── LICENSE └── .gitignore /HMObjcSugar/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default@2x-1.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default@2x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default-667h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default-667h@2x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default-736h@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default-736h@3x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default-Landscape-736h@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Default-Landscape-736h@3x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_button.imageset/tabbar_compose_button@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/tabbar_compose_button.imageset/tabbar_compose_button@2x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_button.imageset/tabbar_compose_button@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/tabbar_compose_button.imageset/tabbar_compose_button@3x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add.imageset/tabbar_compose_icon_add@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add.imageset/tabbar_compose_icon_add@2x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add.imageset/tabbar_compose_icon_add@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add.imageset/tabbar_compose_icon_add@3x.png -------------------------------------------------------------------------------- /HMObjcSugar.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_button_highlighted.imageset/tabbar_compose_button_highlighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/tabbar_compose_button_highlighted.imageset/tabbar_compose_button_highlighted@2x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_button_highlighted.imageset/tabbar_compose_button_highlighted@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/tabbar_compose_button_highlighted.imageset/tabbar_compose_button_highlighted@3x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add_highlighted.imageset/tabbar_compose_icon_add_highlighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add_highlighted.imageset/tabbar_compose_icon_add_highlighted@2x.png -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add_highlighted.imageset/tabbar_compose_icon_add_highlighted@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itheima-developer/HMObjcSugar/HEAD/HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add_highlighted.imageset/tabbar_compose_icon_add_highlighted@3x.png -------------------------------------------------------------------------------- /HMObjcSugar/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /HMObjcSugar/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. 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 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode7 3 | xcode-project: HMObjcSugar.xcodeproj 4 | xcode_scheme: HMObjcSugar 5 | script: 6 | - xctool -project HMObjcSugar.xcodeproj -scheme HMObjcSugar build test -sdk iphonesimulator GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES 7 | after_success: 8 | - bash <(curl -s https://codecov.io/bash) 9 | 10 | -------------------------------------------------------------------------------- /HMObjcSugar/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. 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 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIScreen+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIScreen+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIScreen (HMObjcSugar) 12 | 13 | /// 屏幕宽度 14 | + (CGFloat)hm_screenWidth; 15 | /// 屏幕高度 16 | + (CGFloat)hm_screenHeight; 17 | /// 分辨率 18 | + (CGFloat)hm_scale; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/NSBundle+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSBundle (HMObjcSugar) 12 | 13 | /// 当前版本号字符串 14 | + (nullable NSString *)hm_currentVersion; 15 | 16 | /// 与当前屏幕尺寸匹配的启动图像 17 | + (nullable UIImage *)hm_launchImage; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UINavigationController+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/26. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UINavigationController (HMObjcSugar) 12 | 13 | /// 自定义全屏拖拽返回手势 14 | @property (nonatomic, strong, readonly) UIPanGestureRecognizer *hm_popGestureRecognizer; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIImage+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (HMObjcSugar) 12 | 13 | /// 生成指定颜色的一个`点`的图像 14 | /// 15 | /// @param color 颜色 16 | /// 17 | /// @return 1 * 1 图像 18 | + (nonnull UIImage *)hm_singleDotImageWithColor:(nonnull UIColor *)color; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UITextField+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UITextField+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/24. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UITextField (HMObjcSugar) 12 | 13 | /// 实例化 UITextField 14 | /// 15 | /// @param placeHolder 占位文本 16 | /// 17 | /// @return UITextField 18 | + (nonnull instancetype)hm_textFieldWithPlaceHolder:(nonnull NSString *)placeHolder; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_button.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tabbar_compose_button@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "tabbar_compose_button@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HMObjcSugar/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. 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 | @end 24 | -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tabbar_compose_icon_add@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "tabbar_compose_icon_add@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HMObjcSugar.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "HMObjcSugar" 3 | s.version = "0.0.6" 4 | s.summary = "Objective-C 语法糖" 5 | s.homepage = "https://github.com/itheima-developer/HMObjcSugar" 6 | s.license = "MIT" 7 | s.author = { "Fan Liu" => "liufan321@gamil.com" } 8 | s.platform = :ios, "8.0" 9 | s.source = { :git => "https://github.com/itheima-developer/HMObjcSugar.git", :tag => "#{s.version}" } 10 | s.source_files = "HMObjcSugar/ObjcSugar/*.{h,m}" 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_button_highlighted.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tabbar_compose_button_highlighted@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "tabbar_compose_button_highlighted@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/tabbar_compose_icon_add_highlighted.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tabbar_compose_icon_add_highlighted@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "tabbar_compose_icon_add_highlighted@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIScreen+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIScreen+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "UIScreen+HMObjcSugar.h" 10 | 11 | @implementation UIScreen (HMObjcSugar) 12 | 13 | + (CGFloat)hm_screenWidth { 14 | return [UIScreen mainScreen].bounds.size.width; 15 | } 16 | 17 | + (CGFloat)hm_screenHeight { 18 | return [UIScreen mainScreen].bounds.size.height; 19 | } 20 | 21 | + (CGFloat)hm_scale { 22 | return [UIScreen mainScreen].scale; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HMObjcSugar 2 | Objective-C 语法糖 3 | 4 | [![Build Status](https://travis-ci.org/itheima-developer/HMObjcSugar.svg?branch=master)](https://travis-ci.org/itheima-developer/HMObjcSugar) 5 | [![Cocoapods Compatible](https://img.shields.io/cocoapods/v/HMObjcSugar.svg)](https://img.shields.io/cocoapods/v/HMObjcSugar.svg) 6 | [![Platform](https://img.shields.io/cocoapods/p/HMObjcSugar.svg?style=flat)](http://cocoadocs.org/docsets/HMObjcSugar) 7 | [![codecov.io](https://codecov.io/github/itheima-developer/HMObjcSugar/coverage.svg?branch=master)](https://codecov.io/github/itheima-developer/HMObjcSugar?branch=master) 8 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UITextField+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITextField+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/24. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "UITextField+HMObjcSugar.h" 10 | 11 | @implementation UITextField (HMObjcSugar) 12 | 13 | + (instancetype)hm_textFieldWithPlaceHolder:(NSString *)placeHolder { 14 | 15 | UITextField *textField = [[self alloc] init]; 16 | 17 | textField.borderStyle = UITextBorderStyleRoundedRect; 18 | textField.placeholder = placeHolder; 19 | 20 | return textField; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "UIScreen+HMObjcSugar.h" 10 | #import "UIView+HMObjcSugar.h" 11 | #import "UILabel+HMObjcSugar.h" 12 | #import "UIButton+HMObjcSugar.h" 13 | #import "UITextField+HMObjcSugar.h" 14 | 15 | #import "UIColor+HMObjcSugar.h" 16 | #import "UIImage+HMObjcSugar.h" 17 | 18 | #import "NSBundle+HMObjcSugar.h" 19 | #import "NSDate+HMObjcSugar.h" 20 | #import "NSString+HMObjcSugar.h" 21 | 22 | #import "UINavigationController+HMObjcSugar.h" 23 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIImage+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "UIImage+HMObjcSugar.h" 10 | 11 | @implementation UIImage (HMObjcSugar) 12 | 13 | + (UIImage *)hm_singleDotImageWithColor:(UIColor *)color { 14 | 15 | UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), YES, 0); 16 | 17 | [color setFill]; 18 | UIRectFill(CGRectMake(0, 0, 1, 1)); 19 | 20 | UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); 21 | UIGraphicsEndImageContext(); 22 | 23 | return result; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /HMObjcSugar/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 | } -------------------------------------------------------------------------------- /HMObjcSugarTests/TextFieldSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TextFieldSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/24. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface TextFieldSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation TextFieldSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | - (void)testCreateTextField { 27 | 28 | NSString *placeHolder = @"请输入文本"; 29 | UITextField *textField = [UITextField hm_textFieldWithPlaceHolder:placeHolder]; 30 | 31 | XCTAssertNotNil(textField); 32 | XCTAssert([textField.placeholder isEqualToString:placeHolder]); 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/NSString+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (HMPath) 12 | 13 | /// 拼接了`文档目录`的全路径 14 | @property (nullable, nonatomic, readonly) NSString *hm_documentDirectory; 15 | /// 拼接了`缓存目录`的全路径 16 | @property (nullable, nonatomic, readonly) NSString *hm_cacheDirecotry; 17 | /// 拼接了临时目录的全路径 18 | @property (nullable, nonatomic, readonly) NSString *hm_tmpDirectory; 19 | 20 | @end 21 | 22 | @interface NSString (HMBase64) 23 | 24 | /// BASE 64 编码的字符串内容 25 | @property(nullable, nonatomic, readonly) NSString *hm_base64encode; 26 | /// BASE 64 解码的字符串内容 27 | @property(nullable, nonatomic, readonly) NSString *hm_base64decode; 28 | 29 | @end -------------------------------------------------------------------------------- /HMObjcSugarTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIView+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (HMObjcSugar) 12 | 13 | #pragma mark - Frame 14 | /// 视图原点 15 | @property (nonatomic) CGPoint hm_viewOrigin; 16 | /// 视图尺寸 17 | @property (nonatomic) CGSize hm_viewSize; 18 | 19 | #pragma mark - Frame Origin 20 | /// frame 原点 x 值 21 | @property (nonatomic) CGFloat hm_x; 22 | /// frame 原点 y 值 23 | @property (nonatomic) CGFloat hm_y; 24 | 25 | #pragma mark - Frame Size 26 | /// frame 尺寸 width 27 | @property (nonatomic) CGFloat hm_width; 28 | /// frame 尺寸 height 29 | @property (nonatomic) CGFloat hm_height; 30 | 31 | #pragma mark - 截屏 32 | /// 当前视图内容生成的图像 33 | @property (nonatomic, readonly, nullable)UIImage *hm_capturedImage; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/NSDate+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDate (HMObjcSugar) 12 | 13 | #pragma mark - 单例 14 | + (nonnull NSDateFormatter *)hm_sharedDateFormatter; 15 | + (nonnull NSCalendar *)hm_sharedCalendar; 16 | 17 | #pragma mark - 日期方法 18 | /// 返回指定时间差值的日期字符串 19 | /// 20 | /// @param delta 时间差值 21 | /// 22 | /// @return 日期字符串,格式:yyyy-MM-dd HH:mm:ss 23 | + (nonnull NSString *)hm_dateStringWithDelta:(NSTimeInterval)delta; 24 | 25 | /// 返回日期格式字符串 26 | /// 27 | /// 具体格式如下: 28 | /// - 刚刚(一分钟内) 29 | /// - X分钟前(一小时内) 30 | /// - X小时前(当天) 31 | /// - MM-dd HH:mm(一年内) 32 | /// - yyyy-MM-dd HH:mm(更早期) 33 | @property (nonnull, nonatomic, readonly) NSString *hm_dateDescription; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /HMObjcSugarTests/ScreenSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ScreenSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface ScreenSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation ScreenSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | - (void)testScreenInfo { 27 | CGFloat screenWidth = [UIScreen hm_screenWidth]; 28 | CGFloat screenHeight = [UIScreen hm_screenHeight]; 29 | 30 | CGSize screenSize = [UIScreen mainScreen].bounds.size; 31 | 32 | XCTAssert(CGSizeEqualToSize(screenSize, CGSizeMake(screenWidth, screenHeight)), @"屏幕尺寸错误"); 33 | 34 | CGFloat screenScale = [UIScreen mainScreen].nativeScale; 35 | XCTAssert(screenScale == [UIScreen hm_scale], @"屏幕分辨率错误"); 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /HMObjcSugarTests/BundleSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // BundleSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface BundleSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation BundleSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | - (void)testCurrentVersion { 27 | NSString *versionString = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]; 28 | 29 | XCTAssert([[NSBundle hm_currentVersion] isEqualToString:versionString], @"版本不正确"); 30 | } 31 | 32 | - (void)testLaunchImage { 33 | UIImage *image = [NSBundle hm_launchImage]; 34 | 35 | XCTAssert(image != nil, @"无法找到匹配的启动图片"); 36 | XCTAssert(CGSizeEqualToSize(image.size, [UIScreen mainScreen].bounds.size), @"启动图片尺寸不正确"); 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /HMObjcSugarTests/ImageSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface ImageSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation ImageSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | - (void)testSingleDotImage { 27 | UIImage *image = [UIImage hm_singleDotImageWithColor:[UIColor hm_randomColor]]; 28 | 29 | XCTAssert(CGSizeEqualToSize(image.size, CGSizeMake(1, 1)), @"图像尺寸不正确"); 30 | XCTAssert(image.scale == [UIScreen hm_scale], @"图像分辨率不正确"); 31 | } 32 | 33 | - (void)testSingleDotImagePerformance { 34 | [self measureBlock:^{ 35 | for (int i = 0; i < 10; i++) { 36 | [UIImage hm_singleDotImageWithColor:[UIColor hm_randomColor]]; 37 | } 38 | }]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/NSBundle+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "NSBundle+HMObjcSugar.h" 10 | 11 | @implementation NSBundle (HMObjcSugar) 12 | 13 | + (NSString *)hm_currentVersion { 14 | return [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]; 15 | } 16 | 17 | + (UIImage *)hm_launchImage { 18 | 19 | NSArray *launchImages = [NSBundle mainBundle].infoDictionary[@"UILaunchImages"]; 20 | 21 | NSString *sizeString = NSStringFromCGSize([UIScreen mainScreen].bounds.size); 22 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"UILaunchImageOrientation = 'Portrait' AND UILaunchImageSize = %@", sizeString]; 23 | NSArray *result = [launchImages filteredArrayUsingPredicate:predicate]; 24 | 25 | NSString *imageName = result.lastObject[@"UILaunchImageName"]; 26 | 27 | return [UIImage imageNamed:imageName]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIColor+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (HMObjcSugar) 12 | 13 | #pragma mark - 颜色函数 14 | /// 使用十六进制数字生成颜色 15 | /// 16 | /// @param hex hex,格式 0xFFEEDD 17 | /// 18 | /// @return UIColor 19 | + (nonnull instancetype)hm_colorWithHex:(u_int32_t)hex; 20 | 21 | /// 使用指定的 r / g / b 数值生成颜色 22 | /// 23 | /// @param red red 24 | /// @param green green 25 | /// @param blue blue 26 | /// 27 | /// @return UIColor 28 | + (nonnull instancetype)hm_colorWithRed:(u_int8_t)red green:(u_int8_t)green blue:(u_int8_t)blue; 29 | 30 | /// 生成随机颜色 31 | /// 32 | /// @return UIColor 33 | + (nonnull instancetype)hm_randomColor; 34 | 35 | #pragma mark - 颜色值 36 | /// 返回当前颜色的 red 的 0~255 值 37 | - (u_int8_t)hm_redValue; 38 | /// 返回当前颜色的 green 的 0~255 值 39 | - (u_int8_t)hm_greenValue; 40 | /// 返回当前颜色的 blue 的 0~255 值 41 | - (u_int8_t)hm_blueValue; 42 | /// 返回当前颜色的 alpha 值 43 | - (CGFloat)hm_alphaValue; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 黑马程序员 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 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/NSString+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "NSString+HMObjcSugar.h" 10 | 11 | @implementation NSString (HMPath) 12 | 13 | - (NSString *)hm_documentDirectory { 14 | return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:self]; 15 | } 16 | 17 | - (NSString *)hm_cacheDirecotry { 18 | return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:self]; 19 | } 20 | 21 | - (NSString *)hm_tmpDirectory { 22 | return [NSTemporaryDirectory() stringByAppendingPathComponent:self]; 23 | } 24 | 25 | @end 26 | 27 | @implementation NSString (HMBase64) 28 | 29 | - (NSString *)hm_base64encode { 30 | NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; 31 | 32 | return [data base64EncodedStringWithOptions:0]; 33 | } 34 | 35 | - (NSString *)hm_base64decode { 36 | NSData *data = [[NSData alloc] initWithBase64EncodedString:self options:0]; 37 | 38 | return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /HMObjcSugar/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.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UILabel+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "UILabel+HMObjcSugar.h" 10 | 11 | @implementation UILabel (HMObjcSugar) 12 | 13 | + (instancetype)hm_labelWithText:(NSString *)text { 14 | return [self hm_labelWithText:text fontSize:14 textColor:[UIColor darkGrayColor] alignment:NSTextAlignmentLeft]; 15 | } 16 | 17 | + (instancetype)hm_labelWithText:(NSString *)text fontSize:(CGFloat)fontSize { 18 | return [self hm_labelWithText:text fontSize:fontSize textColor:[UIColor darkGrayColor] alignment:NSTextAlignmentLeft]; 19 | } 20 | 21 | + (instancetype)hm_labelWithText:(NSString *)text fontSize:(CGFloat)fontSize textColor:(UIColor *)textColor { 22 | return [self hm_labelWithText:text fontSize:fontSize textColor:textColor alignment:NSTextAlignmentLeft]; 23 | } 24 | 25 | + (instancetype)hm_labelWithText:(NSString *)text fontSize:(CGFloat)fontSize textColor:(UIColor *)textColor alignment:(NSTextAlignment)alignment { 26 | 27 | UILabel *label = [[self alloc] init]; 28 | 29 | label.text = text; 30 | label.font = [UIFont systemFontOfSize:fontSize]; 31 | label.textColor = textColor; 32 | label.numberOfLines = 0; 33 | label.textAlignment = alignment; 34 | 35 | [label sizeToFit]; 36 | 37 | return label; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIColor+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "UIColor+HMObjcSugar.h" 10 | 11 | @implementation UIColor (HMObjcSugar) 12 | 13 | #pragma mark - 颜色函数 14 | + (instancetype)hm_colorWithHex:(u_int32_t)hex { 15 | u_int8_t red = (hex & 0xFF0000) >> 16; 16 | u_int8_t green = (hex & 0x00FF00) >> 8; 17 | u_int8_t blue = hex & 0x0000FF; 18 | 19 | return [UIColor hm_colorWithRed:red green:green blue:blue]; 20 | } 21 | 22 | + (instancetype)hm_colorWithRed:(u_int8_t)red green:(u_int8_t)green blue:(u_int8_t)blue { 23 | return [UIColor colorWithRed:red / 255.0 green:green / 255.0 blue:blue / 255.0 alpha:1.0]; 24 | } 25 | 26 | + (instancetype)hm_randomColor { 27 | u_int8_t red = arc4random_uniform(256); 28 | u_int8_t green = arc4random_uniform(256); 29 | u_int8_t blue = arc4random_uniform(256); 30 | 31 | return [UIColor hm_colorWithRed:red green:green blue:blue]; 32 | } 33 | 34 | #pragma mark - 颜色值 35 | - (u_int8_t)hm_redValue { 36 | return (u_int8_t)(CGColorGetComponents(self.CGColor)[0] * 255); 37 | } 38 | 39 | - (u_int8_t)hm_greenValue { 40 | return (u_int8_t)(CGColorGetComponents(self.CGColor)[1] * 255); 41 | } 42 | 43 | - (u_int8_t)hm_blueValue { 44 | return (u_int8_t)(CGColorGetComponents(self.CGColor)[2] * 255); 45 | } 46 | 47 | - (CGFloat)hm_alphaValue { 48 | return CGColorGetComponents(self.CGColor)[3]; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UILabel+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UILabel (HMObjcSugar) 12 | 13 | /// 实例化 UILabel 14 | /// 15 | /// @param text text 16 | /// 17 | /// @return UILabel 默认字体 14,默认颜色 [UIColor darkGrayColor],默认对齐方式 Left 18 | + (nonnull instancetype)hm_labelWithText:(nullable NSString *)text; 19 | 20 | /// 实例化 UILabel 21 | /// 22 | /// @param text text 23 | /// @param fontSize fontSize 24 | /// 25 | /// @return UILabel 默认颜色 [UIColor darkGrayColor],默认对齐方式 Left 26 | + (nonnull instancetype)hm_labelWithText:(nullable NSString *)text fontSize:(CGFloat)fontSize; 27 | 28 | /// 实例化 UILabel 29 | /// 30 | /// @param text text 31 | /// @param fontSize fontSize 32 | /// @param textColor textColor 33 | /// 34 | /// @return UILabel 默认对齐方式 Left 35 | + (nonnull instancetype)hm_labelWithText:(nullable NSString *)text 36 | fontSize:(CGFloat)fontSize 37 | textColor:(nonnull UIColor *)textColor; 38 | 39 | /// 实例化 UILabel 40 | /// 41 | /// @param text text 42 | /// @param fontSize fontSize 43 | /// @param textColor textColor 44 | /// @param alignment alignment 45 | /// 46 | /// @return UILabel 47 | + (nonnull instancetype)hm_labelWithText:(nullable NSString *)text 48 | fontSize:(CGFloat)fontSize 49 | textColor:(nonnull UIColor *)textColor 50 | alignment:(NSTextAlignment)alignment; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /HMObjcSugarTests/StringSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // StringSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface StringSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation StringSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | #pragma mark - Path 27 | - (void)testPathProperties { 28 | XCTAssert([@"hello.png".hm_documentDirectory containsString:@"/Documents/"]); 29 | XCTAssert([@"hello.png".hm_cacheDirecotry containsString:@"/Library/Caches/"]); 30 | XCTAssert([@"hello.png".hm_tmpDirectory containsString:@"/tmp/"]); 31 | } 32 | 33 | #pragma mark - BASE64 34 | - (void)testBase64 { 35 | NSString *string = @"Use XCTAssert and related functions to verify your tests produce the correct results."; 36 | 37 | XCTAssert([string isEqualToString:string.hm_base64encode.hm_base64decode], @"BASE 64 编码解码错误"); 38 | // $ echo -n "hello" | base64 39 | XCTAssert([@"hello".hm_base64encode isEqualToString:@"aGVsbG8="], @"BASE 64 编码错误"); 40 | XCTAssert([@"aGVsbG8=".hm_base64decode isEqualToString:@"hello"], @"BASE 64 解码错误"); 41 | } 42 | 43 | - (void)testPerformanceExample { 44 | 45 | NSMutableString *strM = [NSMutableString string]; 46 | for (int i = 0; i < 10000; i++) { 47 | [strM appendString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"]; 48 | } 49 | 50 | [self measureBlock:^{ 51 | XCTAssert([strM isEqualToString:strM.hm_base64encode.hm_base64decode], @"BASE 64 编码解码错误"); 52 | }]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /HMObjcSugar/Assets.xcassets/Brand Assets.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "736h", 7 | "filename" : "Default-736h@3x.png", 8 | "minimum-system-version" : "8.0", 9 | "orientation" : "portrait", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "extent" : "full-screen", 14 | "idiom" : "iphone", 15 | "subtype" : "736h", 16 | "filename" : "Default-Landscape-736h@3x.png", 17 | "minimum-system-version" : "8.0", 18 | "orientation" : "landscape", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "extent" : "full-screen", 23 | "idiom" : "iphone", 24 | "subtype" : "667h", 25 | "filename" : "Default-667h@2x.png", 26 | "minimum-system-version" : "8.0", 27 | "orientation" : "portrait", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "filename" : "Default@2x-1.png", 34 | "extent" : "full-screen", 35 | "minimum-system-version" : "7.0", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "extent" : "full-screen", 40 | "idiom" : "iphone", 41 | "subtype" : "retina4", 42 | "filename" : "Default-568h@2x.png", 43 | "minimum-system-version" : "7.0", 44 | "orientation" : "portrait", 45 | "scale" : "2x" 46 | }, 47 | { 48 | "orientation" : "portrait", 49 | "idiom" : "iphone", 50 | "filename" : "Default.png", 51 | "extent" : "full-screen", 52 | "scale" : "1x" 53 | }, 54 | { 55 | "orientation" : "portrait", 56 | "idiom" : "iphone", 57 | "filename" : "Default@2x.png", 58 | "extent" : "full-screen", 59 | "scale" : "2x" 60 | } 61 | ], 62 | "info" : { 63 | "version" : 1, 64 | "author" : "xcode" 65 | } 66 | } -------------------------------------------------------------------------------- /HMObjcSugarTests/ColorSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ColorSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface ColorSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation ColorSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | #pragma mark - 测试创建颜色 27 | - (void)testColorWithRGB { 28 | XCTAssert([[UIColor hm_colorWithRed:255 green:0 blue:0] isEqual:[UIColor redColor]], @"颜色错误"); 29 | XCTAssert([[UIColor hm_colorWithRed:0 green:255 blue:0] isEqual:[UIColor greenColor]], @"颜色错误"); 30 | XCTAssert([[UIColor hm_colorWithRed:0 green:0 blue:255] isEqual:[UIColor blueColor]], @"颜色错误"); 31 | } 32 | 33 | - (void)testColorWithHEX { 34 | XCTAssert([[UIColor hm_colorWithHex:0xFF0000] isEqual:[UIColor redColor]], @"颜色错误"); 35 | XCTAssert([[UIColor hm_colorWithHex:0x00FF00] isEqual:[UIColor greenColor]], @"颜色错误"); 36 | XCTAssert([[UIColor hm_colorWithHex:0x0000FF] isEqual:[UIColor blueColor]], @"颜色错误"); 37 | } 38 | 39 | - (void)testRandomColor { 40 | XCTAssertNotNil([UIColor hm_randomColor], @"创建颜色错误"); 41 | } 42 | 43 | #pragma mark - 测试颜色值 44 | - (void)testColorValue { 45 | 46 | UIColor *color = [UIColor hm_colorWithHex:0xFF0000]; 47 | XCTAssert(color.hm_redValue == 255 && color.hm_greenValue == 0 && color.hm_blueValue == 0 && color.hm_alphaValue == 1.0); 48 | 49 | u_int8_t r = arc4random_uniform(256); 50 | u_int8_t g = arc4random_uniform(256); 51 | u_int8_t b = arc4random_uniform(256); 52 | 53 | UIColor *randomColor = [UIColor hm_colorWithRed:r green:g blue:b]; 54 | XCTAssert(randomColor.hm_redValue == r && randomColor.hm_greenValue == g && randomColor.hm_blueValue == b && color.hm_alphaValue == 1.0); 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /HMObjcSugarTests/DateSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DateSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface DateSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation DateSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | - (void)testSingleton { 27 | XCTAssert([NSDate hm_sharedDateFormatter] == [NSDate hm_sharedDateFormatter], @"单例地址不一致"); 28 | XCTAssert([NSDate hm_sharedCalendar] == [NSDate hm_sharedCalendar], @"单例地址不一致"); 29 | } 30 | 31 | - (void)testDateStringWithDelta { 32 | 33 | [self checkDateStringWithDelta:24 * 60 * 60]; 34 | [self checkDateStringWithDelta:-24 * 60 * 60]; 35 | [self checkDateStringWithDelta:0]; 36 | // TODO: - -69 年前就计算错误了! 37 | [self checkDateStringWithDelta:-68 * 365 * 24 * 60 * 60]; 38 | } 39 | 40 | - (void)checkDateStringWithDelta:(NSTimeInterval)delta { 41 | NSString *dateString = [NSDate hm_dateStringWithDelta:delta]; 42 | 43 | [NSDate hm_sharedDateFormatter].dateFormat = @"yyyy-MM-dd HH:mm:ss"; 44 | 45 | NSDate *deltaDate = [NSDate dateWithTimeIntervalSinceNow:delta]; 46 | NSString *checkString = [[NSDate hm_sharedDateFormatter] stringFromDate:deltaDate]; 47 | 48 | NSLog(@"%@", dateString); 49 | 50 | XCTAssert([dateString isEqualToString:checkString], @"日期生成错误"); 51 | } 52 | 53 | - (void)testDateDescription { 54 | 55 | XCTAssert([[NSDate dateWithTimeIntervalSinceNow:-59].hm_dateDescription isEqualToString:@"刚刚"]); 56 | XCTAssert([[NSDate dateWithTimeIntervalSinceNow:-10 * 60].hm_dateDescription isEqualToString:@"10 分钟前"]); 57 | XCTAssert([[NSDate dateWithTimeIntervalSinceNow:-1 * 60 * 60].hm_dateDescription isEqualToString:@"1 小时前"]); 58 | 59 | XCTAssert([NSDate dateWithTimeIntervalSinceNow:-24 * 60 * 60].hm_dateDescription.length == 11); 60 | XCTAssert([NSDate dateWithTimeIntervalSinceNow:-365 * 24 * 60 * 60].hm_dateDescription.length == 16); 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /HMObjcSugar/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "HMObjcSugar.h" 11 | 12 | NSString *const cellIdentifier = @"cellIdentifier"; 13 | 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | [self prepareTableView]; 24 | } 25 | 26 | - (void)prepareTableView { 27 | UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; 28 | tableView.dataSource = self; 29 | tableView.delegate = self; 30 | 31 | [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier]; 32 | 33 | [self.view addSubview:tableView]; 34 | } 35 | 36 | - (void)didReceiveMemoryWarning { 37 | [super didReceiveMemoryWarning]; 38 | // Dispose of any resources that can be recreated. 39 | } 40 | 41 | #pragma mark - UITableViewDataSource 42 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 43 | return 100; 44 | } 45 | 46 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 47 | 48 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; 49 | 50 | cell.textLabel.text = @(indexPath.row).stringValue; 51 | 52 | return cell; 53 | } 54 | 55 | #pragma mark - UITableViewDelegate 56 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 57 | 58 | UIViewController *vc = [[UIViewController alloc] init]; 59 | vc.view.backgroundColor = [UIColor hm_randomColor]; 60 | 61 | vc.hidesBottomBarWhenPushed = YES; 62 | 63 | // 如果不设置背景颜色,拖拽手势返回的时候,右上角会有黑色 64 | self.navigationController.view.backgroundColor = [UIColor whiteColor]; 65 | 66 | [self.navigationController pushViewController:vc animated:YES]; 67 | } 68 | 69 | @end -------------------------------------------------------------------------------- /HMObjcSugar.xcodeproj/xcshareddata/xcschemes/HMObjcSugarTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 14 | 15 | 17 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 39 | 40 | 41 | 42 | 48 | 49 | 51 | 52 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIView+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "UIView+HMObjcSugar.h" 10 | 11 | @implementation UIView (HMObjcSugar) 12 | 13 | #pragma mark - Frame 14 | - (CGPoint)hm_viewOrigin { 15 | return self.frame.origin; 16 | } 17 | 18 | - (void)setHm_viewOrigin:(CGPoint)hm_viewOrigin { 19 | CGRect newFrame = self.frame; 20 | newFrame.origin = hm_viewOrigin; 21 | self.frame = newFrame; 22 | } 23 | 24 | - (CGSize)hm_viewSize { 25 | return self.frame.size; 26 | } 27 | 28 | - (void)setHm_viewSize:(CGSize)hm_viewSize { 29 | CGRect newFrame = self.frame; 30 | newFrame.size = hm_viewSize; 31 | self.frame = newFrame; 32 | } 33 | 34 | #pragma mark - Frame Origin 35 | - (CGFloat)hm_x { 36 | return self.frame.origin.x; 37 | } 38 | 39 | - (void)setHm_x:(CGFloat)hm_x { 40 | CGRect newFrame = self.frame; 41 | newFrame.origin.x = hm_x; 42 | self.frame = newFrame; 43 | } 44 | 45 | - (CGFloat)hm_y { 46 | return self.frame.origin.y; 47 | } 48 | 49 | - (void)setHm_y:(CGFloat)hm_y { 50 | CGRect newFrame = self.frame; 51 | newFrame.origin.y = hm_y; 52 | self.frame = newFrame; 53 | } 54 | 55 | #pragma mark - Frame Size 56 | - (CGFloat)hm_width { 57 | return self.frame.size.width; 58 | } 59 | 60 | - (void)setHm_width:(CGFloat)hm_width { 61 | CGRect newFrame = self.frame; 62 | newFrame.size.width = hm_width; 63 | self.frame = newFrame; 64 | } 65 | 66 | - (CGFloat)hm_height { 67 | return self.frame.size.height; 68 | } 69 | 70 | - (void)setHm_height:(CGFloat)hm_height { 71 | CGRect newFrame = self.frame; 72 | newFrame.size.height = hm_height; 73 | self.frame = newFrame; 74 | } 75 | 76 | #pragma mark - 截屏 77 | - (UIImage *)hm_capturedImage { 78 | 79 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, 0); 80 | 81 | UIImage *result = nil; 82 | if ([self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES]) { 83 | result = UIGraphicsGetImageFromCurrentImageContext(); 84 | } 85 | 86 | UIGraphicsEndImageContext(); 87 | 88 | return result; 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/NSDate+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "NSDate+HMObjcSugar.h" 10 | 11 | @implementation NSDate (HMObjcSugar) 12 | 13 | #pragma mark - 单例 14 | + (NSDateFormatter *)hm_sharedDateFormatter { 15 | static NSDateFormatter *dateFormatter; 16 | 17 | static dispatch_once_t onceToken; 18 | dispatch_once(&onceToken, ^{ 19 | dateFormatter = [[NSDateFormatter alloc] init]; 20 | dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en"]; 21 | }); 22 | 23 | return dateFormatter; 24 | } 25 | 26 | + (NSCalendar *)hm_sharedCalendar { 27 | static NSCalendar *calendar; 28 | 29 | static dispatch_once_t onceToken; 30 | dispatch_once(&onceToken, ^{ 31 | calendar = [NSCalendar currentCalendar]; 32 | }); 33 | 34 | return calendar; 35 | } 36 | 37 | #pragma mark - 日期方法 38 | + (NSString *)hm_dateStringWithDelta:(NSTimeInterval)delta { 39 | [self hm_sharedDateFormatter].dateFormat = @"yyyy-MM-dd HH:mm:ss"; 40 | 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:delta]; 42 | 43 | return [[self hm_sharedDateFormatter] stringFromDate:date]; 44 | } 45 | 46 | - (NSString *)hm_dateDescription { 47 | 48 | NSUInteger units = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; 49 | NSDateComponents *dateComponents = [[NSDate hm_sharedCalendar] components:units fromDate:self]; 50 | NSDateComponents *thisComponents = [[NSDate hm_sharedCalendar] components:units fromDate:[NSDate date]]; 51 | 52 | // 今天 53 | if (dateComponents.year == thisComponents.year 54 | && dateComponents.month == thisComponents.month 55 | && dateComponents.day == thisComponents.day) { 56 | 57 | NSInteger delta = (NSInteger)[[NSDate date] timeIntervalSinceDate:self]; 58 | 59 | if (delta < 60) { 60 | return @"刚刚"; 61 | } 62 | if (delta < 3600) { 63 | return [NSString stringWithFormat:@"%zd 分钟前", delta / 60]; 64 | } 65 | return [NSString stringWithFormat:@"%zd 小时前", delta / 3600]; 66 | } 67 | 68 | NSString *format = @"MM-dd HH:mm"; 69 | 70 | if (dateComponents.year != thisComponents.year) { 71 | format = [@"yyyy-" stringByAppendingString:format]; 72 | } 73 | [NSDate hm_sharedDateFormatter].dateFormat = format; 74 | 75 | return [[NSDate hm_sharedDateFormatter] stringFromDate:self]; 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /HMObjcSugarTests/LabelSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // LabelSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface LabelSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation LabelSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | - (void)testCreateLabel { 27 | 28 | NSString *string = @"hello label"; 29 | CGFloat fontSize = 17; 30 | UIColor *textColor = [UIColor hm_randomColor]; 31 | NSTextAlignment alignment = NSTextAlignmentCenter; 32 | 33 | { 34 | UILabel *label = [UILabel hm_labelWithText:string]; 35 | [self checkLabelInfo:label withString:string fontSize:14 textColor:[UIColor darkGrayColor] alignment:NSTextAlignmentLeft]; 36 | } 37 | 38 | { 39 | UILabel *label = [UILabel hm_labelWithText:string fontSize:fontSize]; 40 | [self checkLabelInfo:label withString:string fontSize:fontSize textColor:[UIColor darkGrayColor] alignment:NSTextAlignmentLeft]; 41 | } 42 | 43 | { 44 | UILabel *label = [UILabel hm_labelWithText:string fontSize:fontSize textColor:textColor]; 45 | [self checkLabelInfo:label withString:string fontSize:fontSize textColor:textColor alignment:NSTextAlignmentLeft]; 46 | } 47 | 48 | { 49 | UILabel *label = [UILabel hm_labelWithText:string fontSize:fontSize textColor:textColor alignment:alignment]; 50 | 51 | [self checkLabelInfo:label withString:string fontSize:fontSize textColor:textColor alignment:alignment]; 52 | } 53 | 54 | } 55 | 56 | - (void)checkLabelInfo:(UILabel *)label 57 | withString:(NSString *)string 58 | fontSize:(CGFloat)fontSize 59 | textColor:(UIColor *)textColor 60 | alignment:(NSTextAlignment)alignment { 61 | 62 | XCTAssert([label.text isEqualToString:string], @"文本不正确"); 63 | XCTAssert(label.font.pointSize == fontSize, @"字体大小不正确"); 64 | XCTAssert([label.textColor isEqual:textColor], @"颜色不正确"); 65 | XCTAssert(label.textAlignment == alignment, @"对齐方式不正确"); 66 | 67 | CGSize labelSize = [string boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) 68 | options:NSStringDrawingUsesLineFragmentOrigin 69 | attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:fontSize]} 70 | context:nil].size; 71 | 72 | XCTAssert(ceil(labelSize.width) == ceil(label.bounds.size.width), @"宽度不正确"); 73 | XCTAssert(ceil(labelSize.height) == ceil(label.bounds.size.height), @"高度不正确"); 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /HMObjcSugarTests/ViewSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/20. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface ViewSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation ViewSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | #pragma mark - 测试 Frame 27 | - (void)testOriginSize { 28 | UIView *view = [[UIView alloc] init]; 29 | 30 | CGPoint origin = CGPointMake(arc4random_uniform(100), arc4random_uniform(100)); 31 | CGSize size = CGSizeMake(arc4random_uniform(300), arc4random_uniform(300)); 32 | CGRect rect = (CGRect) { .origin = origin, .size = size }; 33 | 34 | view.hm_viewOrigin = origin; 35 | view.hm_viewSize = size; 36 | 37 | [self checkViewFrame:view withRect:rect]; 38 | } 39 | 40 | - (void)testXYWidthHeight { 41 | 42 | UIView *view = [[UIView alloc] init]; 43 | 44 | CGFloat x = arc4random_uniform(100); 45 | CGFloat y = arc4random_uniform(100); 46 | CGFloat w = arc4random_uniform(300); 47 | CGFloat h = arc4random_uniform(600); 48 | 49 | view.hm_x = x; 50 | view.hm_y = y; 51 | view.hm_width = w; 52 | view.hm_height = h; 53 | 54 | [self checkViewFrame:view withRect:CGRectMake(x, y, w, h)]; 55 | } 56 | 57 | - (void)checkViewFrame:(UIView *)view withRect:(CGRect)rect { 58 | 59 | XCTAssert(rect.origin.x == view.hm_x, @"x 不一致"); 60 | XCTAssert(rect.origin.y == view.hm_y, @"y 不一致"); 61 | XCTAssert(rect.size.width == view.hm_width, @"width 不一致"); 62 | XCTAssert(rect.size.height == view.hm_height, @"height 不一致"); 63 | 64 | XCTAssert(CGPointEqualToPoint(rect.origin, view.hm_viewOrigin), @"原点不一致"); 65 | XCTAssert(CGSizeEqualToSize(rect.size, view.hm_viewSize), @"尺寸不一致"); 66 | XCTAssert(CGRectEqualToRect(rect, view.frame), @"frame 不一致"); 67 | } 68 | 69 | - (void)testCapturedImage { 70 | 71 | CGFloat w = arc4random_uniform([UIScreen hm_screenWidth]); 72 | CGFloat h = arc4random_uniform([UIScreen hm_screenHeight]); 73 | 74 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, w, h)]; 75 | UIImage *image = [view hm_capturedImage]; 76 | 77 | XCTAssert(CGSizeEqualToSize(image.size, CGSizeMake(w, h)), @"图像尺寸错误"); 78 | } 79 | 80 | - (void)testCapturedImagePerformance { 81 | 82 | [self measureBlock:^{ 83 | CGFloat w = arc4random_uniform([UIScreen hm_screenWidth]); 84 | CGFloat h = arc4random_uniform([UIScreen hm_screenHeight]); 85 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, w, h)]; 86 | view.backgroundColor = [UIColor hm_randomColor]; 87 | 88 | [view hm_capturedImage]; 89 | }]; 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /HMObjcSugar/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 | 47 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIButton+HMObjcSugar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+HMObjcSugar.h 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIButton (HMObjcSugar) 12 | 13 | /// 实例化 UIButton 14 | /// 15 | /// @param title title 16 | /// @param fontSize fontSize 17 | /// @param textColor textColor 18 | /// 19 | /// @return UIButton 20 | + (nonnull instancetype)hm_buttonWithTitle:(nullable NSString *)title 21 | fontSize:(CGFloat)fontSize 22 | textColor:(nonnull UIColor *)textColor; 23 | 24 | /// 实例化 UIButton 25 | /// 26 | /// @param attributedText attributedText 27 | /// 28 | /// @return UIButton 29 | + (nonnull instancetype)hm_buttonWithAttributedText:(nullable NSAttributedString *)attributedText; 30 | 31 | /// 实例化 UIButton 32 | /// 33 | /// @param imageName imageName 34 | /// @param highlightSuffix highlightSuffix 35 | /// 36 | /// @return UIButton 37 | + (nonnull instancetype)hm_buttonWithImageName:(nullable NSString *)imageName 38 | highlightSuffix:(nullable NSString *)highlightSuffix; 39 | 40 | /// 实例化 UIButton 41 | /// 42 | /// @param imageName imageName 43 | /// @param backImageName backImageName 44 | /// @param highlightSuffix highlightSuffix 45 | /// 46 | /// @return UIButton 47 | + (nonnull instancetype)hm_buttonWithImageName:(nullable NSString *)imageName 48 | backImageName:(nullable NSString *)backImageName 49 | highlightSuffix:(nullable NSString *)highlightSuffix; 50 | 51 | /// 实例化 UIButton 52 | /// 53 | /// @param title title 54 | /// @param fontSize fontSize 55 | /// @param textColor textColor 56 | /// @param imageName imageName 57 | /// @param backImageName backImageName 58 | /// @param highlightSuffix highlightSuffix 59 | /// 60 | /// @return UIButton 61 | + (nonnull instancetype)hm_buttonWithTitle:(nullable NSString *)title 62 | fontSize:(CGFloat)fontSize 63 | textColor:(nonnull UIColor *)textColor 64 | imageName:(nullable NSString *)imageName 65 | backImageName:(nullable NSString *)backImageName 66 | highlightSuffix:(nullable NSString *)highlightSuffix; 67 | 68 | /// 实例化 UIButton 69 | /// 70 | /// @param attributedText attributedText 71 | /// @param imageName imageName 72 | /// @param backImageName backImageName 73 | /// @param highlightSuffix highlightSuffix 74 | /// 75 | /// @return UIButton 76 | + (nonnull instancetype)hm_buttonWithAttributedText:(nullable NSAttributedString *)attributedText 77 | imageName:(nullable NSString *)imageName 78 | backImageName:(nullable NSString *)backImageName 79 | highlightSuffix:(nullable NSString *)highlightSuffix; 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UIButton+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "UIButton+HMObjcSugar.h" 10 | 11 | @implementation UIButton (HMObjcSugar) 12 | 13 | + (instancetype)hm_buttonWithTitle:(NSString *)title fontSize:(CGFloat)fontSize textColor:(UIColor *)textColor { 14 | NSAttributedString *attributedText = [[NSAttributedString alloc] 15 | initWithString:title 16 | attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:fontSize], 17 | NSForegroundColorAttributeName: textColor}]; 18 | 19 | return [self hm_buttonWithAttributedText:attributedText]; 20 | } 21 | 22 | + (instancetype)hm_buttonWithAttributedText:(NSAttributedString *)attributedText { 23 | return [self hm_buttonWithAttributedText:attributedText imageName:nil backImageName:nil highlightSuffix:nil]; 24 | } 25 | 26 | + (instancetype)hm_buttonWithImageName:(NSString *)imageName highlightSuffix:(NSString *)highlightSuffix { 27 | 28 | return [self hm_buttonWithAttributedText:nil imageName:imageName backImageName:nil highlightSuffix:highlightSuffix]; 29 | } 30 | 31 | + (instancetype)hm_buttonWithImageName:(NSString *)imageName backImageName:(NSString *)backImageName highlightSuffix:(NSString *)highlightSuffix { 32 | 33 | return [self hm_buttonWithAttributedText:nil imageName:imageName backImageName:backImageName highlightSuffix:highlightSuffix]; 34 | } 35 | 36 | + (instancetype)hm_buttonWithTitle:(NSString *)title fontSize:(CGFloat)fontSize textColor:(UIColor *)textColor imageName:(NSString *)imageName backImageName:(NSString *)backImageName highlightSuffix:(NSString *)highlightSuffix { 37 | 38 | NSAttributedString *attributedText = [[NSAttributedString alloc] 39 | initWithString:title 40 | attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:fontSize], 41 | NSForegroundColorAttributeName: textColor}]; 42 | 43 | return [self hm_buttonWithAttributedText:attributedText imageName:imageName backImageName:backImageName highlightSuffix:highlightSuffix]; 44 | } 45 | 46 | + (instancetype)hm_buttonWithAttributedText:(NSAttributedString *)attributedText imageName:(NSString *)imageName backImageName:(NSString *)backImageName highlightSuffix:(NSString *)highlightSuffix { 47 | 48 | UIButton *button = [[self alloc] init]; 49 | 50 | [button setAttributedTitle:attributedText forState:UIControlStateNormal]; 51 | 52 | if (imageName != nil) { 53 | [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal]; 54 | 55 | NSString *highlightedImageName = [imageName stringByAppendingString:highlightSuffix]; 56 | [button setImage:[UIImage imageNamed:highlightedImageName] forState:UIControlStateHighlighted]; 57 | } 58 | 59 | if (backImageName != nil) { 60 | [button setBackgroundImage:[UIImage imageNamed:backImageName] forState:UIControlStateNormal]; 61 | 62 | NSString *highlightedImageName = [backImageName stringByAppendingString:highlightSuffix]; 63 | [button setBackgroundImage:[UIImage imageNamed:highlightedImageName] forState:UIControlStateHighlighted]; 64 | } 65 | 66 | [button sizeToFit]; 67 | 68 | return button; 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /HMObjcSugar/ObjcSugar/UINavigationController+HMObjcSugar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+HMObjcSugar.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/26. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import "UINavigationController+HMObjcSugar.h" 10 | #import 11 | 12 | @interface HMFullScreenPopGestureRecognizerDelegate : NSObject 13 | 14 | @property (nonatomic, weak) UINavigationController *navigationController; 15 | 16 | @end 17 | 18 | @implementation HMFullScreenPopGestureRecognizerDelegate 19 | 20 | - (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer { 21 | 22 | if (self.navigationController.viewControllers.count <= 1) { 23 | return NO; 24 | } 25 | 26 | if ([[self.navigationController valueForKey:@"_isTransitioning"] boolValue]) { 27 | return NO; 28 | } 29 | 30 | CGPoint translation = [gestureRecognizer translationInView:gestureRecognizer.view]; 31 | if (translation.x <= 0) { 32 | return NO; 33 | } 34 | 35 | return YES; 36 | } 37 | 38 | @end 39 | 40 | @implementation UINavigationController (HMObjcSugar) 41 | 42 | + (void)load { 43 | 44 | Method originalMethod = class_getInstanceMethod([self class], @selector(pushViewController:animated:)); 45 | Method swizzledMethod = class_getInstanceMethod([self class], @selector(hm_pushViewController:animated:)); 46 | 47 | method_exchangeImplementations(originalMethod, swizzledMethod); 48 | } 49 | 50 | - (void)hm_pushViewController:(UIViewController *)viewController animated:(BOOL)animated { 51 | 52 | if (![self.interactivePopGestureRecognizer.view.gestureRecognizers containsObject:self.hm_popGestureRecognizer]) { 53 | [self.interactivePopGestureRecognizer.view addGestureRecognizer:self.hm_popGestureRecognizer]; 54 | 55 | NSArray *targets = [self.interactivePopGestureRecognizer valueForKey:@"targets"]; 56 | id internalTarget = [targets.firstObject valueForKey:@"target"]; 57 | SEL internalAction = NSSelectorFromString(@"handleNavigationTransition:"); 58 | 59 | self.hm_popGestureRecognizer.delegate = [self hm_fullScreenPopGestureRecognizerDelegate]; 60 | [self.hm_popGestureRecognizer addTarget:internalTarget action:internalAction]; 61 | 62 | // 禁用系统的交互手势 63 | self.interactivePopGestureRecognizer.enabled = NO; 64 | } 65 | 66 | if (![self.viewControllers containsObject:viewController]) { 67 | [self hm_pushViewController:viewController animated:animated]; 68 | } 69 | } 70 | 71 | - (HMFullScreenPopGestureRecognizerDelegate *)hm_fullScreenPopGestureRecognizerDelegate { 72 | HMFullScreenPopGestureRecognizerDelegate *delegate = objc_getAssociatedObject(self, _cmd); 73 | if (!delegate) { 74 | delegate = [[HMFullScreenPopGestureRecognizerDelegate alloc] init]; 75 | delegate.navigationController = self; 76 | 77 | objc_setAssociatedObject(self, _cmd, delegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 78 | } 79 | return delegate; 80 | } 81 | 82 | - (UIPanGestureRecognizer *)hm_popGestureRecognizer { 83 | UIPanGestureRecognizer *panGestureRecognizer = objc_getAssociatedObject(self, _cmd); 84 | 85 | if (panGestureRecognizer == nil) { 86 | panGestureRecognizer = [[UIPanGestureRecognizer alloc] init]; 87 | panGestureRecognizer.maximumNumberOfTouches = 1; 88 | 89 | objc_setAssociatedObject(self, _cmd, panGestureRecognizer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 90 | } 91 | return panGestureRecognizer; 92 | } 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /HMObjcSugarTests/ButtonSugarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ButtonSugarTests.m 3 | // HMObjcSugar 4 | // 5 | // Created by 刘凡 on 16/3/21. 6 | // Copyright © 2016年 itcast. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HMObjcSugar.h" 11 | 12 | @interface ButtonSugarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation ButtonSugarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | - (void)testCreateImageButton { 27 | 28 | NSString *imageName = @"tabbar_compose_icon_add"; 29 | NSString *backImageName = @"tabbar_compose_button"; 30 | NSString *suffix = @"_highlighted"; 31 | 32 | UIImage *image = [UIImage imageNamed:imageName]; 33 | UIImage *backImage = [UIImage imageNamed:backImageName]; 34 | 35 | // --- 测试图像按钮 --- 36 | { 37 | UIButton *button = [UIButton hm_buttonWithImageName:imageName highlightSuffix:suffix]; 38 | 39 | XCTAssert(CGSizeEqualToSize(button.bounds.size, image.size), @"按钮尺寸错误"); 40 | } 41 | // --- 测试 图像 & 背景图像 按钮 --- 42 | { 43 | UIButton *button = [UIButton hm_buttonWithImageName:imageName backImageName:backImageName highlightSuffix:suffix]; 44 | 45 | XCTAssert(CGSizeEqualToSize(button.bounds.size, backImage.size), @"按钮尺寸错误"); 46 | } 47 | } 48 | 49 | - (void)testCreateTextButton { 50 | 51 | NSString *title = @"hello button"; 52 | CGFloat fontSize = 17; 53 | UIColor *textColor = [UIColor hm_randomColor]; 54 | 55 | NSAttributedString *attributedText = [[NSAttributedString alloc] 56 | initWithString:title 57 | attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:fontSize], 58 | NSForegroundColorAttributeName: textColor}]; 59 | CGSize size = [attributedText boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) 60 | options:NSStringDrawingUsesLineFragmentOrigin 61 | context:nil].size; 62 | 63 | // --- 测试文本按钮 --- 64 | { 65 | UIButton *button = [UIButton hm_buttonWithTitle:title fontSize:fontSize textColor:textColor]; 66 | 67 | XCTAssert(button.bounds.size.width == ceil(size.width), @"宽度不正确"); 68 | } 69 | 70 | // --- 测试属性文本按钮 --- 71 | { 72 | UIButton *button = [UIButton hm_buttonWithAttributedText:attributedText]; 73 | 74 | XCTAssert(button.bounds.size.width == ceil(size.width), @"宽度不正确"); 75 | } 76 | } 77 | 78 | - (void)testCreateTextImageButton { 79 | NSString *title = @"hello button"; 80 | CGFloat fontSize = 17; 81 | UIColor *textColor = [UIColor hm_randomColor]; 82 | 83 | NSAttributedString *attributedText = [[NSAttributedString alloc] 84 | initWithString:title 85 | attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:fontSize], 86 | NSForegroundColorAttributeName: textColor}]; 87 | CGSize size = [attributedText boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) 88 | options:NSStringDrawingUsesLineFragmentOrigin 89 | context:nil].size; 90 | 91 | NSString *backImageName = @"tabbar_compose_button"; 92 | NSString *suffix = @"_highlighted"; 93 | 94 | // --- 测试文本背景图像按钮 --- 95 | { 96 | UIButton *button = [UIButton hm_buttonWithTitle:title fontSize:fontSize textColor:textColor imageName:nil backImageName:backImageName highlightSuffix:suffix]; 97 | 98 | XCTAssert(button.bounds.size.width == ceil(size.width), @"宽度不正确"); 99 | } 100 | 101 | // --- 测试属性文本背景图像按钮 --- 102 | { 103 | UIButton *button = [UIButton hm_buttonWithAttributedText:attributedText imageName:nil backImageName:backImageName highlightSuffix:suffix]; 104 | 105 | XCTAssert(button.bounds.size.width == ceil(size.width), @"宽度不正确"); 106 | } 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /HMObjcSugar.xcodeproj/xcshareddata/xcschemes/HMObjcSugar.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /HMObjcSugar.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C212EF671CA3305B0016E4EB /* UITextField+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C212EF661CA3305B0016E4EB /* UITextField+HMObjcSugar.m */; }; 11 | C212EF691CA331100016E4EB /* TextFieldSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C212EF681CA331100016E4EB /* TextFieldSugarTests.m */; }; 12 | C237AA4D1C9EAF0A0008B377 /* UIView+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA4C1C9EAF0A0008B377 /* UIView+HMObjcSugar.m */; }; 13 | C237AA521C9EAFD30008B377 /* ViewSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA511C9EAFD30008B377 /* ViewSugarTests.m */; }; 14 | C237AA551C9EBA9F0008B377 /* UIScreen+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA541C9EBA9F0008B377 /* UIScreen+HMObjcSugar.m */; }; 15 | C237AA571C9EBB660008B377 /* ScreenSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA561C9EBB660008B377 /* ScreenSugarTests.m */; }; 16 | C237AA5A1C9F89D70008B377 /* UIImage+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA591C9F89D70008B377 /* UIImage+HMObjcSugar.m */; }; 17 | C237AA5C1C9F8B210008B377 /* ImageSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA5B1C9F8B210008B377 /* ImageSugarTests.m */; }; 18 | C237AA5F1C9F8D960008B377 /* UILabel+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA5E1C9F8D960008B377 /* UILabel+HMObjcSugar.m */; }; 19 | C237AA611C9F8E870008B377 /* LabelSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA601C9F8E870008B377 /* LabelSugarTests.m */; }; 20 | C237AA641C9F9AC60008B377 /* UIButton+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA631C9F9AC60008B377 /* UIButton+HMObjcSugar.m */; }; 21 | C237AA661C9FA30F0008B377 /* ButtonSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA651C9FA30F0008B377 /* ButtonSugarTests.m */; }; 22 | C237AA691C9FAE7B0008B377 /* NSBundle+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA681C9FAE7B0008B377 /* NSBundle+HMObjcSugar.m */; }; 23 | C237AA6B1C9FAF3B0008B377 /* BundleSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA6A1C9FAF3B0008B377 /* BundleSugarTests.m */; }; 24 | C237AA6E1C9FBDC80008B377 /* NSDate+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA6D1C9FBDC80008B377 /* NSDate+HMObjcSugar.m */; }; 25 | C237AA701C9FC0240008B377 /* DateSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AA6F1C9FC0240008B377 /* DateSugarTests.m */; }; 26 | C237AAA71C9FD5410008B377 /* NSString+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AAA61C9FD5410008B377 /* NSString+HMObjcSugar.m */; }; 27 | C237AAAB1C9FDEDE0008B377 /* StringSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C237AAAA1C9FDEDE0008B377 /* StringSugarTests.m */; }; 28 | C2BE24351CA5A8F100C773D8 /* UINavigationController+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C2BE24341CA5A8F100C773D8 /* UINavigationController+HMObjcSugar.m */; }; 29 | C2C53ED11C9E2678006DB9DB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2C53ED01C9E2678006DB9DB /* main.m */; }; 30 | C2C53ED41C9E2678006DB9DB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C2C53ED31C9E2678006DB9DB /* AppDelegate.m */; }; 31 | C2C53ED71C9E2678006DB9DB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C2C53ED61C9E2678006DB9DB /* ViewController.m */; }; 32 | C2C53EDA1C9E2678006DB9DB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C2C53ED81C9E2678006DB9DB /* Main.storyboard */; }; 33 | C2C53EDC1C9E2678006DB9DB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C2C53EDB1C9E2678006DB9DB /* Assets.xcassets */; }; 34 | C2C53EF81C9E2AA1006DB9DB /* UIColor+HMObjcSugar.m in Sources */ = {isa = PBXBuildFile; fileRef = C2C53EF71C9E2AA1006DB9DB /* UIColor+HMObjcSugar.m */; }; 35 | C2C53EFB1C9E2BF0006DB9DB /* ColorSugarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C2C53EFA1C9E2BEF006DB9DB /* ColorSugarTests.m */; }; 36 | /* End PBXBuildFile section */ 37 | 38 | /* Begin PBXContainerItemProxy section */ 39 | C2C53EE61C9E2678006DB9DB /* PBXContainerItemProxy */ = { 40 | isa = PBXContainerItemProxy; 41 | containerPortal = C2C53EC41C9E2678006DB9DB /* Project object */; 42 | proxyType = 1; 43 | remoteGlobalIDString = C2C53ECB1C9E2678006DB9DB; 44 | remoteInfo = HMObjcSugar; 45 | }; 46 | /* End PBXContainerItemProxy section */ 47 | 48 | /* Begin PBXFileReference section */ 49 | C212EF651CA3305B0016E4EB /* UITextField+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITextField+HMObjcSugar.h"; sourceTree = ""; }; 50 | C212EF661CA3305B0016E4EB /* UITextField+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITextField+HMObjcSugar.m"; sourceTree = ""; }; 51 | C212EF681CA331100016E4EB /* TextFieldSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextFieldSugarTests.m; sourceTree = ""; }; 52 | C237AA4B1C9EAF0A0008B377 /* UIView+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+HMObjcSugar.h"; sourceTree = ""; }; 53 | C237AA4C1C9EAF0A0008B377 /* UIView+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+HMObjcSugar.m"; sourceTree = ""; }; 54 | C237AA511C9EAFD30008B377 /* ViewSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewSugarTests.m; sourceTree = ""; }; 55 | C237AA531C9EBA9F0008B377 /* UIScreen+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScreen+HMObjcSugar.h"; sourceTree = ""; }; 56 | C237AA541C9EBA9F0008B377 /* UIScreen+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScreen+HMObjcSugar.m"; sourceTree = ""; }; 57 | C237AA561C9EBB660008B377 /* ScreenSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScreenSugarTests.m; sourceTree = ""; }; 58 | C237AA581C9F89D70008B377 /* UIImage+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+HMObjcSugar.h"; sourceTree = ""; }; 59 | C237AA591C9F89D70008B377 /* UIImage+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+HMObjcSugar.m"; sourceTree = ""; }; 60 | C237AA5B1C9F8B210008B377 /* ImageSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageSugarTests.m; sourceTree = ""; }; 61 | C237AA5D1C9F8D960008B377 /* UILabel+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UILabel+HMObjcSugar.h"; sourceTree = ""; }; 62 | C237AA5E1C9F8D960008B377 /* UILabel+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UILabel+HMObjcSugar.m"; sourceTree = ""; }; 63 | C237AA601C9F8E870008B377 /* LabelSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LabelSugarTests.m; sourceTree = ""; }; 64 | C237AA621C9F9AC60008B377 /* UIButton+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+HMObjcSugar.h"; sourceTree = ""; }; 65 | C237AA631C9F9AC60008B377 /* UIButton+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+HMObjcSugar.m"; sourceTree = ""; }; 66 | C237AA651C9FA30F0008B377 /* ButtonSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ButtonSugarTests.m; sourceTree = ""; }; 67 | C237AA671C9FAE7A0008B377 /* NSBundle+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSBundle+HMObjcSugar.h"; sourceTree = ""; }; 68 | C237AA681C9FAE7B0008B377 /* NSBundle+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+HMObjcSugar.m"; sourceTree = ""; }; 69 | C237AA6A1C9FAF3B0008B377 /* BundleSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BundleSugarTests.m; sourceTree = ""; }; 70 | C237AA6C1C9FBDC80008B377 /* NSDate+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+HMObjcSugar.h"; sourceTree = ""; }; 71 | C237AA6D1C9FBDC80008B377 /* NSDate+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+HMObjcSugar.m"; sourceTree = ""; }; 72 | C237AA6F1C9FC0240008B377 /* DateSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DateSugarTests.m; sourceTree = ""; }; 73 | C237AAA51C9FD5410008B377 /* NSString+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+HMObjcSugar.h"; sourceTree = ""; }; 74 | C237AAA61C9FD5410008B377 /* NSString+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+HMObjcSugar.m"; sourceTree = ""; }; 75 | C237AAAA1C9FDEDE0008B377 /* StringSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StringSugarTests.m; sourceTree = ""; }; 76 | C2BE24331CA5A8F100C773D8 /* UINavigationController+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+HMObjcSugar.h"; sourceTree = ""; }; 77 | C2BE24341CA5A8F100C773D8 /* UINavigationController+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+HMObjcSugar.m"; sourceTree = ""; }; 78 | C2C53ECC1C9E2678006DB9DB /* HMObjcSugar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HMObjcSugar.app; sourceTree = BUILT_PRODUCTS_DIR; }; 79 | C2C53ED01C9E2678006DB9DB /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 80 | C2C53ED21C9E2678006DB9DB /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 81 | C2C53ED31C9E2678006DB9DB /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 82 | C2C53ED51C9E2678006DB9DB /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 83 | C2C53ED61C9E2678006DB9DB /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 84 | C2C53ED91C9E2678006DB9DB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 85 | C2C53EDB1C9E2678006DB9DB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 86 | C2C53EE01C9E2678006DB9DB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 87 | C2C53EE51C9E2678006DB9DB /* HMObjcSugarTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HMObjcSugarTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 88 | C2C53EEB1C9E2678006DB9DB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 89 | C2C53EF51C9E2A3F006DB9DB /* HMObjcSugar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HMObjcSugar.h; sourceTree = ""; }; 90 | C2C53EF61C9E2AA1006DB9DB /* UIColor+HMObjcSugar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+HMObjcSugar.h"; sourceTree = ""; }; 91 | C2C53EF71C9E2AA1006DB9DB /* UIColor+HMObjcSugar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+HMObjcSugar.m"; sourceTree = ""; }; 92 | C2C53EFA1C9E2BEF006DB9DB /* ColorSugarTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ColorSugarTests.m; sourceTree = ""; }; 93 | /* End PBXFileReference section */ 94 | 95 | /* Begin PBXFrameworksBuildPhase section */ 96 | C2C53EC91C9E2678006DB9DB /* Frameworks */ = { 97 | isa = PBXFrameworksBuildPhase; 98 | buildActionMask = 2147483647; 99 | files = ( 100 | ); 101 | runOnlyForDeploymentPostprocessing = 0; 102 | }; 103 | C2C53EE21C9E2678006DB9DB /* Frameworks */ = { 104 | isa = PBXFrameworksBuildPhase; 105 | buildActionMask = 2147483647; 106 | files = ( 107 | ); 108 | runOnlyForDeploymentPostprocessing = 0; 109 | }; 110 | /* End PBXFrameworksBuildPhase section */ 111 | 112 | /* Begin PBXGroup section */ 113 | C2C53EC31C9E2678006DB9DB = { 114 | isa = PBXGroup; 115 | children = ( 116 | C2C53ECE1C9E2678006DB9DB /* HMObjcSugar */, 117 | C2C53EE81C9E2678006DB9DB /* HMObjcSugarTests */, 118 | C2C53ECD1C9E2678006DB9DB /* Products */, 119 | ); 120 | sourceTree = ""; 121 | }; 122 | C2C53ECD1C9E2678006DB9DB /* Products */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | C2C53ECC1C9E2678006DB9DB /* HMObjcSugar.app */, 126 | C2C53EE51C9E2678006DB9DB /* HMObjcSugarTests.xctest */, 127 | ); 128 | name = Products; 129 | sourceTree = ""; 130 | }; 131 | C2C53ECE1C9E2678006DB9DB /* HMObjcSugar */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | C2C53EF41C9E268E006DB9DB /* ObjcSugar */, 135 | C2C53ED21C9E2678006DB9DB /* AppDelegate.h */, 136 | C2C53ED31C9E2678006DB9DB /* AppDelegate.m */, 137 | C2C53ED51C9E2678006DB9DB /* ViewController.h */, 138 | C2C53ED61C9E2678006DB9DB /* ViewController.m */, 139 | C2C53ED81C9E2678006DB9DB /* Main.storyboard */, 140 | C2C53EDB1C9E2678006DB9DB /* Assets.xcassets */, 141 | C2C53EE01C9E2678006DB9DB /* Info.plist */, 142 | C2C53ECF1C9E2678006DB9DB /* Supporting Files */, 143 | ); 144 | path = HMObjcSugar; 145 | sourceTree = ""; 146 | }; 147 | C2C53ECF1C9E2678006DB9DB /* Supporting Files */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | C2C53ED01C9E2678006DB9DB /* main.m */, 151 | ); 152 | name = "Supporting Files"; 153 | sourceTree = ""; 154 | }; 155 | C2C53EE81C9E2678006DB9DB /* HMObjcSugarTests */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | C237AA561C9EBB660008B377 /* ScreenSugarTests.m */, 159 | C237AA511C9EAFD30008B377 /* ViewSugarTests.m */, 160 | C237AA601C9F8E870008B377 /* LabelSugarTests.m */, 161 | C237AA651C9FA30F0008B377 /* ButtonSugarTests.m */, 162 | C212EF681CA331100016E4EB /* TextFieldSugarTests.m */, 163 | C237AA5B1C9F8B210008B377 /* ImageSugarTests.m */, 164 | C2C53EFA1C9E2BEF006DB9DB /* ColorSugarTests.m */, 165 | C237AA6A1C9FAF3B0008B377 /* BundleSugarTests.m */, 166 | C237AA6F1C9FC0240008B377 /* DateSugarTests.m */, 167 | C237AAAA1C9FDEDE0008B377 /* StringSugarTests.m */, 168 | C2C53EEB1C9E2678006DB9DB /* Info.plist */, 169 | ); 170 | path = HMObjcSugarTests; 171 | sourceTree = ""; 172 | }; 173 | C2C53EF41C9E268E006DB9DB /* ObjcSugar */ = { 174 | isa = PBXGroup; 175 | children = ( 176 | C2C53EF51C9E2A3F006DB9DB /* HMObjcSugar.h */, 177 | C237AA531C9EBA9F0008B377 /* UIScreen+HMObjcSugar.h */, 178 | C237AA541C9EBA9F0008B377 /* UIScreen+HMObjcSugar.m */, 179 | C237AA4B1C9EAF0A0008B377 /* UIView+HMObjcSugar.h */, 180 | C237AA4C1C9EAF0A0008B377 /* UIView+HMObjcSugar.m */, 181 | C237AA5D1C9F8D960008B377 /* UILabel+HMObjcSugar.h */, 182 | C237AA5E1C9F8D960008B377 /* UILabel+HMObjcSugar.m */, 183 | C237AA621C9F9AC60008B377 /* UIButton+HMObjcSugar.h */, 184 | C237AA631C9F9AC60008B377 /* UIButton+HMObjcSugar.m */, 185 | C212EF651CA3305B0016E4EB /* UITextField+HMObjcSugar.h */, 186 | C212EF661CA3305B0016E4EB /* UITextField+HMObjcSugar.m */, 187 | C237AA581C9F89D70008B377 /* UIImage+HMObjcSugar.h */, 188 | C237AA591C9F89D70008B377 /* UIImage+HMObjcSugar.m */, 189 | C2C53EF61C9E2AA1006DB9DB /* UIColor+HMObjcSugar.h */, 190 | C2C53EF71C9E2AA1006DB9DB /* UIColor+HMObjcSugar.m */, 191 | C237AA671C9FAE7A0008B377 /* NSBundle+HMObjcSugar.h */, 192 | C237AA681C9FAE7B0008B377 /* NSBundle+HMObjcSugar.m */, 193 | C237AA6C1C9FBDC80008B377 /* NSDate+HMObjcSugar.h */, 194 | C237AA6D1C9FBDC80008B377 /* NSDate+HMObjcSugar.m */, 195 | C237AAA51C9FD5410008B377 /* NSString+HMObjcSugar.h */, 196 | C237AAA61C9FD5410008B377 /* NSString+HMObjcSugar.m */, 197 | C2BE24331CA5A8F100C773D8 /* UINavigationController+HMObjcSugar.h */, 198 | C2BE24341CA5A8F100C773D8 /* UINavigationController+HMObjcSugar.m */, 199 | ); 200 | path = ObjcSugar; 201 | sourceTree = ""; 202 | }; 203 | /* End PBXGroup section */ 204 | 205 | /* Begin PBXNativeTarget section */ 206 | C2C53ECB1C9E2678006DB9DB /* HMObjcSugar */ = { 207 | isa = PBXNativeTarget; 208 | buildConfigurationList = C2C53EEE1C9E2678006DB9DB /* Build configuration list for PBXNativeTarget "HMObjcSugar" */; 209 | buildPhases = ( 210 | C2C53EC81C9E2678006DB9DB /* Sources */, 211 | C2C53EC91C9E2678006DB9DB /* Frameworks */, 212 | C2C53ECA1C9E2678006DB9DB /* Resources */, 213 | ); 214 | buildRules = ( 215 | ); 216 | dependencies = ( 217 | ); 218 | name = HMObjcSugar; 219 | productName = HMObjcSugar; 220 | productReference = C2C53ECC1C9E2678006DB9DB /* HMObjcSugar.app */; 221 | productType = "com.apple.product-type.application"; 222 | }; 223 | C2C53EE41C9E2678006DB9DB /* HMObjcSugarTests */ = { 224 | isa = PBXNativeTarget; 225 | buildConfigurationList = C2C53EF11C9E2678006DB9DB /* Build configuration list for PBXNativeTarget "HMObjcSugarTests" */; 226 | buildPhases = ( 227 | C2C53EE11C9E2678006DB9DB /* Sources */, 228 | C2C53EE21C9E2678006DB9DB /* Frameworks */, 229 | C2C53EE31C9E2678006DB9DB /* Resources */, 230 | ); 231 | buildRules = ( 232 | ); 233 | dependencies = ( 234 | C2C53EE71C9E2678006DB9DB /* PBXTargetDependency */, 235 | ); 236 | name = HMObjcSugarTests; 237 | productName = HMObjcSugarTests; 238 | productReference = C2C53EE51C9E2678006DB9DB /* HMObjcSugarTests.xctest */; 239 | productType = "com.apple.product-type.bundle.unit-test"; 240 | }; 241 | /* End PBXNativeTarget section */ 242 | 243 | /* Begin PBXProject section */ 244 | C2C53EC41C9E2678006DB9DB /* Project object */ = { 245 | isa = PBXProject; 246 | attributes = { 247 | LastUpgradeCheck = 0730; 248 | ORGANIZATIONNAME = itcast; 249 | TargetAttributes = { 250 | C2C53ECB1C9E2678006DB9DB = { 251 | CreatedOnToolsVersion = 7.3; 252 | }; 253 | C2C53EE41C9E2678006DB9DB = { 254 | CreatedOnToolsVersion = 7.3; 255 | TestTargetID = C2C53ECB1C9E2678006DB9DB; 256 | }; 257 | }; 258 | }; 259 | buildConfigurationList = C2C53EC71C9E2678006DB9DB /* Build configuration list for PBXProject "HMObjcSugar" */; 260 | compatibilityVersion = "Xcode 3.2"; 261 | developmentRegion = English; 262 | hasScannedForEncodings = 0; 263 | knownRegions = ( 264 | en, 265 | Base, 266 | ); 267 | mainGroup = C2C53EC31C9E2678006DB9DB; 268 | productRefGroup = C2C53ECD1C9E2678006DB9DB /* Products */; 269 | projectDirPath = ""; 270 | projectRoot = ""; 271 | targets = ( 272 | C2C53ECB1C9E2678006DB9DB /* HMObjcSugar */, 273 | C2C53EE41C9E2678006DB9DB /* HMObjcSugarTests */, 274 | ); 275 | }; 276 | /* End PBXProject section */ 277 | 278 | /* Begin PBXResourcesBuildPhase section */ 279 | C2C53ECA1C9E2678006DB9DB /* Resources */ = { 280 | isa = PBXResourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | C2C53EDC1C9E2678006DB9DB /* Assets.xcassets in Resources */, 284 | C2C53EDA1C9E2678006DB9DB /* Main.storyboard in Resources */, 285 | ); 286 | runOnlyForDeploymentPostprocessing = 0; 287 | }; 288 | C2C53EE31C9E2678006DB9DB /* Resources */ = { 289 | isa = PBXResourcesBuildPhase; 290 | buildActionMask = 2147483647; 291 | files = ( 292 | ); 293 | runOnlyForDeploymentPostprocessing = 0; 294 | }; 295 | /* End PBXResourcesBuildPhase section */ 296 | 297 | /* Begin PBXSourcesBuildPhase section */ 298 | C2C53EC81C9E2678006DB9DB /* Sources */ = { 299 | isa = PBXSourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | C2C53ED71C9E2678006DB9DB /* ViewController.m in Sources */, 303 | C237AA551C9EBA9F0008B377 /* UIScreen+HMObjcSugar.m in Sources */, 304 | C2C53EF81C9E2AA1006DB9DB /* UIColor+HMObjcSugar.m in Sources */, 305 | C2BE24351CA5A8F100C773D8 /* UINavigationController+HMObjcSugar.m in Sources */, 306 | C212EF671CA3305B0016E4EB /* UITextField+HMObjcSugar.m in Sources */, 307 | C237AA5A1C9F89D70008B377 /* UIImage+HMObjcSugar.m in Sources */, 308 | C237AA6E1C9FBDC80008B377 /* NSDate+HMObjcSugar.m in Sources */, 309 | C237AA691C9FAE7B0008B377 /* NSBundle+HMObjcSugar.m in Sources */, 310 | C2C53ED41C9E2678006DB9DB /* AppDelegate.m in Sources */, 311 | C237AA4D1C9EAF0A0008B377 /* UIView+HMObjcSugar.m in Sources */, 312 | C237AA641C9F9AC60008B377 /* UIButton+HMObjcSugar.m in Sources */, 313 | C237AAA71C9FD5410008B377 /* NSString+HMObjcSugar.m in Sources */, 314 | C237AA5F1C9F8D960008B377 /* UILabel+HMObjcSugar.m in Sources */, 315 | C2C53ED11C9E2678006DB9DB /* main.m in Sources */, 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | C2C53EE11C9E2678006DB9DB /* Sources */ = { 320 | isa = PBXSourcesBuildPhase; 321 | buildActionMask = 2147483647; 322 | files = ( 323 | C237AA6B1C9FAF3B0008B377 /* BundleSugarTests.m in Sources */, 324 | C2C53EFB1C9E2BF0006DB9DB /* ColorSugarTests.m in Sources */, 325 | C237AAAB1C9FDEDE0008B377 /* StringSugarTests.m in Sources */, 326 | C237AA571C9EBB660008B377 /* ScreenSugarTests.m in Sources */, 327 | C237AA611C9F8E870008B377 /* LabelSugarTests.m in Sources */, 328 | C237AA5C1C9F8B210008B377 /* ImageSugarTests.m in Sources */, 329 | C237AA661C9FA30F0008B377 /* ButtonSugarTests.m in Sources */, 330 | C237AA701C9FC0240008B377 /* DateSugarTests.m in Sources */, 331 | C212EF691CA331100016E4EB /* TextFieldSugarTests.m in Sources */, 332 | C237AA521C9EAFD30008B377 /* ViewSugarTests.m in Sources */, 333 | ); 334 | runOnlyForDeploymentPostprocessing = 0; 335 | }; 336 | /* End PBXSourcesBuildPhase section */ 337 | 338 | /* Begin PBXTargetDependency section */ 339 | C2C53EE71C9E2678006DB9DB /* PBXTargetDependency */ = { 340 | isa = PBXTargetDependency; 341 | target = C2C53ECB1C9E2678006DB9DB /* HMObjcSugar */; 342 | targetProxy = C2C53EE61C9E2678006DB9DB /* PBXContainerItemProxy */; 343 | }; 344 | /* End PBXTargetDependency section */ 345 | 346 | /* Begin PBXVariantGroup section */ 347 | C2C53ED81C9E2678006DB9DB /* Main.storyboard */ = { 348 | isa = PBXVariantGroup; 349 | children = ( 350 | C2C53ED91C9E2678006DB9DB /* Base */, 351 | ); 352 | name = Main.storyboard; 353 | sourceTree = ""; 354 | }; 355 | /* End PBXVariantGroup section */ 356 | 357 | /* Begin XCBuildConfiguration section */ 358 | C2C53EEC1C9E2678006DB9DB /* Debug */ = { 359 | isa = XCBuildConfiguration; 360 | buildSettings = { 361 | ALWAYS_SEARCH_USER_PATHS = NO; 362 | CLANG_ANALYZER_NONNULL = YES; 363 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 364 | CLANG_CXX_LIBRARY = "libc++"; 365 | CLANG_ENABLE_MODULES = YES; 366 | CLANG_ENABLE_OBJC_ARC = YES; 367 | CLANG_WARN_BOOL_CONVERSION = YES; 368 | CLANG_WARN_CONSTANT_CONVERSION = YES; 369 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 370 | CLANG_WARN_EMPTY_BODY = YES; 371 | CLANG_WARN_ENUM_CONVERSION = YES; 372 | CLANG_WARN_INT_CONVERSION = YES; 373 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 374 | CLANG_WARN_UNREACHABLE_CODE = YES; 375 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 376 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 377 | COPY_PHASE_STRIP = NO; 378 | DEBUG_INFORMATION_FORMAT = dwarf; 379 | ENABLE_STRICT_OBJC_MSGSEND = YES; 380 | ENABLE_TESTABILITY = YES; 381 | GCC_C_LANGUAGE_STANDARD = gnu99; 382 | GCC_DYNAMIC_NO_PIC = NO; 383 | GCC_NO_COMMON_BLOCKS = YES; 384 | GCC_OPTIMIZATION_LEVEL = 0; 385 | GCC_PREPROCESSOR_DEFINITIONS = ( 386 | "DEBUG=1", 387 | "$(inherited)", 388 | ); 389 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 390 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 391 | GCC_WARN_UNDECLARED_SELECTOR = YES; 392 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 393 | GCC_WARN_UNUSED_FUNCTION = YES; 394 | GCC_WARN_UNUSED_VARIABLE = YES; 395 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 396 | MTL_ENABLE_DEBUG_INFO = YES; 397 | ONLY_ACTIVE_ARCH = YES; 398 | SDKROOT = iphoneos; 399 | }; 400 | name = Debug; 401 | }; 402 | C2C53EED1C9E2678006DB9DB /* Release */ = { 403 | isa = XCBuildConfiguration; 404 | buildSettings = { 405 | ALWAYS_SEARCH_USER_PATHS = NO; 406 | CLANG_ANALYZER_NONNULL = YES; 407 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 408 | CLANG_CXX_LIBRARY = "libc++"; 409 | CLANG_ENABLE_MODULES = YES; 410 | CLANG_ENABLE_OBJC_ARC = YES; 411 | CLANG_WARN_BOOL_CONVERSION = YES; 412 | CLANG_WARN_CONSTANT_CONVERSION = YES; 413 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 414 | CLANG_WARN_EMPTY_BODY = YES; 415 | CLANG_WARN_ENUM_CONVERSION = YES; 416 | CLANG_WARN_INT_CONVERSION = YES; 417 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 418 | CLANG_WARN_UNREACHABLE_CODE = YES; 419 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 420 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 421 | COPY_PHASE_STRIP = NO; 422 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 423 | ENABLE_NS_ASSERTIONS = NO; 424 | ENABLE_STRICT_OBJC_MSGSEND = YES; 425 | GCC_C_LANGUAGE_STANDARD = gnu99; 426 | GCC_NO_COMMON_BLOCKS = YES; 427 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 428 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 429 | GCC_WARN_UNDECLARED_SELECTOR = YES; 430 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 431 | GCC_WARN_UNUSED_FUNCTION = YES; 432 | GCC_WARN_UNUSED_VARIABLE = YES; 433 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 434 | MTL_ENABLE_DEBUG_INFO = NO; 435 | SDKROOT = iphoneos; 436 | VALIDATE_PRODUCT = YES; 437 | }; 438 | name = Release; 439 | }; 440 | C2C53EEF1C9E2678006DB9DB /* Debug */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 444 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; 445 | INFOPLIST_FILE = HMObjcSugar/Info.plist; 446 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 447 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 448 | PRODUCT_BUNDLE_IDENTIFIER = cn.itcast.HMObjcSugar; 449 | PRODUCT_NAME = "$(TARGET_NAME)"; 450 | }; 451 | name = Debug; 452 | }; 453 | C2C53EF01C9E2678006DB9DB /* Release */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 457 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; 458 | INFOPLIST_FILE = HMObjcSugar/Info.plist; 459 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 460 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 461 | PRODUCT_BUNDLE_IDENTIFIER = cn.itcast.HMObjcSugar; 462 | PRODUCT_NAME = "$(TARGET_NAME)"; 463 | }; 464 | name = Release; 465 | }; 466 | C2C53EF21C9E2678006DB9DB /* Debug */ = { 467 | isa = XCBuildConfiguration; 468 | buildSettings = { 469 | BUNDLE_LOADER = "$(TEST_HOST)"; 470 | INFOPLIST_FILE = HMObjcSugarTests/Info.plist; 471 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 472 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 473 | PRODUCT_BUNDLE_IDENTIFIER = cn.itcast.HMObjcSugarTests; 474 | PRODUCT_NAME = "$(TARGET_NAME)"; 475 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HMObjcSugar.app/HMObjcSugar"; 476 | }; 477 | name = Debug; 478 | }; 479 | C2C53EF31C9E2678006DB9DB /* Release */ = { 480 | isa = XCBuildConfiguration; 481 | buildSettings = { 482 | BUNDLE_LOADER = "$(TEST_HOST)"; 483 | INFOPLIST_FILE = HMObjcSugarTests/Info.plist; 484 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 485 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 486 | PRODUCT_BUNDLE_IDENTIFIER = cn.itcast.HMObjcSugarTests; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HMObjcSugar.app/HMObjcSugar"; 489 | }; 490 | name = Release; 491 | }; 492 | /* End XCBuildConfiguration section */ 493 | 494 | /* Begin XCConfigurationList section */ 495 | C2C53EC71C9E2678006DB9DB /* Build configuration list for PBXProject "HMObjcSugar" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | C2C53EEC1C9E2678006DB9DB /* Debug */, 499 | C2C53EED1C9E2678006DB9DB /* Release */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | defaultConfigurationName = Release; 503 | }; 504 | C2C53EEE1C9E2678006DB9DB /* Build configuration list for PBXNativeTarget "HMObjcSugar" */ = { 505 | isa = XCConfigurationList; 506 | buildConfigurations = ( 507 | C2C53EEF1C9E2678006DB9DB /* Debug */, 508 | C2C53EF01C9E2678006DB9DB /* Release */, 509 | ); 510 | defaultConfigurationIsVisible = 0; 511 | defaultConfigurationName = Release; 512 | }; 513 | C2C53EF11C9E2678006DB9DB /* Build configuration list for PBXNativeTarget "HMObjcSugarTests" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | C2C53EF21C9E2678006DB9DB /* Debug */, 517 | C2C53EF31C9E2678006DB9DB /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | /* End XCConfigurationList section */ 523 | }; 524 | rootObject = C2C53EC41C9E2678006DB9DB /* Project object */; 525 | } 526 | --------------------------------------------------------------------------------