├── ERHandPainting ├── WechatIMG.jpeg ├── HandPaintViewController.h ├── AppDelegate.h ├── main.m ├── HandPainting │ ├── Stroke.h │ ├── HandPaintingImageView.h │ ├── Stroke.m │ └── HandPaintingImageView.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── AppDelegate.m └── HandPaintViewController.m ├── ERHandPainting.xcodeproj ├── xcuserdata │ └── huguangyu.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── ERHandPainting.xcscheme ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── huguangyu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── project.pbxproj ├── ERHandPainting.podspec ├── ERHandPaintingTests ├── Info.plist └── ERHandPaintingTests.m ├── ERHandPaintingUITests ├── Info.plist └── ERHandPaintingUITests.m ├── LICENSE └── README.md /ERHandPainting/WechatIMG.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErHu1993/ERHandPainting/HEAD/ERHandPainting/WechatIMG.jpeg -------------------------------------------------------------------------------- /ERHandPainting.xcodeproj/xcuserdata/huguangyu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ERHandPainting.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ERHandPainting.xcodeproj/project.xcworkspace/xcuserdata/huguangyu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ErHu1993/ERHandPainting/HEAD/ERHandPainting.xcodeproj/project.xcworkspace/xcuserdata/huguangyu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ERHandPainting/HandPaintViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HandPaintViewController.h 3 | // ErHuDemo 4 | // 5 | // Created by 胡广宇 on 2017/6/1. 6 | // Copyright © 2017年 胡广宇. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HandPaintViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ERHandPainting/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ERHandPainting 4 | // 5 | // Created by 胡广宇 on 2017/7/10. 6 | // Copyright © 2017年 胡广宇. 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 | -------------------------------------------------------------------------------- /ERHandPainting/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ERHandPainting 4 | // 5 | // Created by 胡广宇 on 2017/7/10. 6 | // Copyright © 2017年 胡广宇. 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 | -------------------------------------------------------------------------------- /ERHandPainting.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | s.name = "ERHandPainting" 4 | s.version = "0.0.1" 5 | s.summary = "You Can drawn on UIImageView" 6 | s.homepage = "https://github.com/ErHu1993/ERHandPainting" 7 | s.license= { :type => "MIT", :file => "LICENSE" } 8 | s.author = { "huguangyu" => "199301055@qq.com" } 9 | s.source = { :git => "https://github.com/ErHu1993/ERHandPainting.git", :tag => "s.version" } 10 | s.source_files = "HandPainting/*" 11 | s.ios.deployment_target = "7.0" 12 | end 13 | -------------------------------------------------------------------------------- /ERHandPainting/HandPainting/Stroke.h: -------------------------------------------------------------------------------- 1 | // 2 | // Stroke.h 3 | // ErHuDemo 4 | // 5 | // Created by 胡广宇 on 2017/6/2. 6 | // Copyright © 2017年 胡广宇. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface Stroke : NSObject 12 | // 笔画经过的点 13 | @property (nonatomic, strong ,readonly) NSMutableArray *points; 14 | // 缓存的创建好的贝塞尔曲线 15 | @property (nonatomic, strong) UIBezierPath *path; 16 | 17 | - (instancetype)initWithColor:(UIColor *)color width:(CGFloat)width; 18 | 19 | - (void)pass:(CGPoint)point; 20 | 21 | - (void)draw; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /ERHandPaintingTests/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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ERHandPaintingUITests/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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ERHandPainting.xcodeproj/xcuserdata/huguangyu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ERHandPainting.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D85CD3D41F13157100CE5640 16 | 17 | primary 18 | 19 | 20 | D85CD3ED1F13157100CE5640 21 | 22 | primary 23 | 24 | 25 | D85CD3F81F13157100CE5640 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ERHandPainting/HandPainting/HandPaintingImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HandPaintingImageView.h 3 | // ErHuDemo 4 | // 5 | // Created by 胡广宇 on 2017/6/2. 6 | // Copyright © 2017年 胡广宇. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HandPaintingImageView : UIImageView 12 | 13 | /** 14 | 只需调用一次,必须先设置Image(重要), 15 | 16 | @param widthInMM 标注的宽度,单位毫米 17 | */ 18 | - (void)hp_initWidthInMM:(double)widthInMM; 19 | 20 | 21 | /** 22 | 绘图时选中某种颜色 23 | 24 | @param color color 25 | @param abstractScale 当前缩放倍数,默认1.0 26 | */ 27 | - (void)hp_chooseWithColor:(UIColor *)color abstractScale:(CGFloat)abstractScale; 28 | 29 | /** 30 | 当图片缩放比发生变化时,传入绝对的缩放比 31 | 32 | @param scale 当前缩放倍数 33 | */ 34 | - (void)hp_setAbsoluteScale:(CGFloat)scale; 35 | 36 | /** 37 | 离开绘图页面时取消选中颜色 38 | */ 39 | - (void)hp_unchoose; 40 | 41 | /** 42 | 撤销绘图 43 | */ 44 | - (void)hp_undo; 45 | 46 | /** 47 | 是否进行过标注(用于结束时判断是否需要将标注draw到image上) 48 | 49 | @return bool 50 | */ 51 | - (BOOL)hp_hasStocks; 52 | 53 | /** 54 | 标注过的图片需要通过此方法将标注与原图混合 55 | */ 56 | - (void)hp_drawOnImage; 57 | @end 58 | -------------------------------------------------------------------------------- /ERHandPaintingTests/ERHandPaintingTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ERHandPaintingTests.m 3 | // ERHandPaintingTests 4 | // 5 | // Created by 胡广宇 on 2017/7/10. 6 | // Copyright © 2017年 胡广宇. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ERHandPaintingTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ERHandPaintingTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /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 of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /ERHandPaintingUITests/ERHandPaintingUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ERHandPaintingUITests.m 3 | // ERHandPaintingUITests 4 | // 5 | // Created by 胡广宇 on 2017/7/10. 6 | // Copyright © 2017年 胡广宇. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ERHandPaintingUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ERHandPaintingUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ERHandPainting/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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ERHandPainting 2 | 3 | ## 在imageView上进行手绘 4 | ![](http://upload-images.jianshu.io/upload_images/2773241-3bafcc7f5756ee8b.gif?imageMogr2/auto-orient/strip) 5 | 6 | ## 使用方法: 7 | 8 | #### ``` pod 'ERHandPainting' ``` 9 | 10 | #### ``` #import ``` 11 | 12 | #### 创建一个HandPaintingImageView 13 | ``` @property (nonatomic, strong) HandPaintingImageView *paintingImageView; ``` 14 | 15 | #### 初始化并赋值Image后,再初始化画笔 16 | ``` 17 | [_paintingImageView hp_initWidthInMM:2.5];//初始化画笔宽度 18 | [_paintingImageView hp_chooseWithColor:[UIColor blueColor] abstractScale:self.backGroundScrollerView.zoomScale];//选中颜色和放大倍数(一般用于和UIScrollerView混合用,如果没有直接传1.0) 19 | 20 | ``` 21 | 22 | #### 提供以下方法供调用 23 | 24 | ``` 25 | /** 26 | 只需调用一次,必须先设置Image(重要), 27 | 28 | @param widthInMM 标注的宽度,单位毫米 29 | */ 30 | - (void)hp_initWidthInMM:(double)widthInMM; 31 | 32 | 33 | /** 34 | 绘图时选中某种颜色 35 | 36 | @param color color 37 | @param abstractScale 当前缩放倍数,默认1.0 38 | */ 39 | - (void)hp_chooseWithColor:(UIColor *)color abstractScale:(CGFloat)abstractScale; 40 | 41 | /** 42 | 当图片缩放比发生变化时,传入绝对的缩放比 43 | 44 | @param scale 当前缩放倍数 45 | */ 46 | - (void)hp_setAbsoluteScale:(CGFloat)scale; 47 | 48 | /** 49 | 离开绘图页面时取消选中颜色 50 | */ 51 | - (void)hp_unchoose; 52 | 53 | /** 54 | 撤销绘图 55 | */ 56 | - (void)hp_undo; 57 | 58 | /** 59 | 是否进行过标注(用于结束时判断是否需要将标注draw到image上) 60 | 61 | @return bool 62 | */ 63 | - (BOOL)hp_hasStocks; 64 | 65 | /** 66 | 标注过的图片需要通过此方法将标注与原图混合 67 | */ 68 | - (void)hp_drawOnImage; 69 | ``` 70 | 71 | 72 | -------------------------------------------------------------------------------- /ERHandPainting/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.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSPhotoLibraryUsageDescription 24 | 相册 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ERHandPainting/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ERHandPainting/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 | -------------------------------------------------------------------------------- /ERHandPainting/HandPainting/Stroke.m: -------------------------------------------------------------------------------- 1 | // 2 | // Stroke.m 3 | // ErHuDemo 4 | // 5 | // Created by 胡广宇 on 2017/6/2. 6 | // Copyright © 2017年 胡广宇. All rights reserved. 7 | // 8 | 9 | #import "Stroke.h" 10 | 11 | @interface Stroke () 12 | 13 | @property (nonatomic, strong) UIColor *color; 14 | 15 | @property (nonatomic, assign) CGFloat width; 16 | 17 | @end 18 | 19 | @implementation Stroke{ 20 | NSMutableArray *_points; 21 | CGFloat DD; 22 | } 23 | 24 | - (instancetype)initWithColor:(UIColor *)color width:(CGFloat)width{ 25 | if (self = [super init]) { 26 | 27 | _points = [NSMutableArray array]; 28 | 29 | DD = 3.0 / [UIScreen mainScreen].scale; 30 | 31 | self.color = color; 32 | self.width = width; 33 | } 34 | return self; 35 | } 36 | 37 | - (void)pass:(CGPoint)point{ 38 | if (!_points.count) { 39 | CGContextRef context = UIGraphicsGetCurrentContext(); 40 | if (context) { 41 | CGContextSetStrokeColorWithColor(context, self.color.CGColor); 42 | } 43 | 44 | self.path = [UIBezierPath bezierPath]; 45 | self.path.lineWidth = self.width; 46 | self.path.lineCapStyle = kCGLineCapRound; 47 | self.path.lineJoinStyle = kCGLineJoinRound; 48 | [self.path moveToPoint:point]; 49 | [self.path addLineToPoint:point]; 50 | [_points addObject:[NSValue valueWithCGPoint:point]]; 51 | } 52 | 53 | CGPoint last = [_points.lastObject CGPointValue]; 54 | NSInteger dx = ABS(point.x - last.x); 55 | NSInteger dy = ABS(point.y - last.y); 56 | 57 | if (dx >= DD || dy >= DD ) { 58 | [self.path addQuadCurveToPoint:CGPointMake((point.x + last.x) / 2, (point.y + last.y) / 2) controlPoint:last]; 59 | [_points addObject:[NSValue valueWithCGPoint:point]]; 60 | } 61 | } 62 | 63 | - (void)draw{ 64 | if (self.path) { 65 | CGContextRef context = UIGraphicsGetCurrentContext(); 66 | if (context) { 67 | CGContextSetStrokeColorWithColor(context, self.color.CGColor); 68 | } 69 | [self.path stroke]; 70 | } 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /ERHandPainting/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ERHandPainting 4 | // 5 | // Created by 胡广宇 on 2017/7/10. 6 | // Copyright © 2017年 胡广宇. 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 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ERHandPainting.xcodeproj/xcuserdata/huguangyu.xcuserdatad/xcschemes/ERHandPainting.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /ERHandPainting/HandPaintViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HandPaintViewController.m 3 | // ErHuDemo 4 | // 5 | // Created by 胡广宇 on 2017/6/1. 6 | // Copyright © 2017年 胡广宇. All rights reserved. 7 | // 8 | 9 | #import "HandPaintViewController.h" 10 | #import "HandPaintingImageView.h" 11 | 12 | @interface HandPaintViewController () 13 | 14 | @property (nonatomic, strong) HandPaintingImageView *paintingImageView; 15 | 16 | @property (nonatomic, strong) UIScrollView *backGroundScrollerView; 17 | 18 | @end 19 | 20 | @implementation HandPaintViewController 21 | 22 | - (void)dealloc{ 23 | 24 | } 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | [self setupSubViews]; 29 | } 30 | 31 | - (void)setupSubViews{ 32 | //单指手绘 , 双指滑动图片 33 | [self setMaxMinZoomScalesForCurrentBounds]; 34 | 35 | UIButton *backBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, 20, 80, 80)]; 36 | [backBtn setTitle:@"revoke" forState:UIControlStateNormal]; 37 | [backBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 38 | [backBtn addTarget:self action:@selector(revoke) forControlEvents:UIControlEventTouchUpInside]; 39 | [self.view addSubview:backBtn]; 40 | 41 | UIButton *saveBtn = [[UIButton alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 80 - 20, 20, 80, 80)]; 42 | [saveBtn setTitle:@"save" forState:UIControlStateNormal]; 43 | [saveBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; 44 | [saveBtn addTarget:self action:@selector(save) forControlEvents:UIControlEventTouchUpInside]; 45 | [self.view addSubview:saveBtn]; 46 | 47 | UIButton *changeBtn = [[UIButton alloc] initWithFrame:CGRectMake(saveBtn.frame.origin.x, 20 + 80 + 20, 80, 80)]; 48 | [changeBtn setTitle:@"Color" forState:UIControlStateNormal]; 49 | [changeBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 50 | [changeBtn addTarget:self action:@selector(changeColor) forControlEvents:UIControlEventTouchUpInside]; 51 | [self.view addSubview:changeBtn]; 52 | } 53 | 54 | - (void)back{ 55 | [self.paintingImageView hp_unchoose]; 56 | [self dismissViewControllerAnimated:YES completion:nil]; 57 | } 58 | 59 | - (void)save{ 60 | if ([self.paintingImageView hp_hasStocks]) { 61 | [self.paintingImageView hp_drawOnImage]; 62 | } 63 | 64 | UIImageWriteToSavedPhotosAlbum(self.paintingImageView.image,self, @selector(resultImage:didFinishSavingWithError:contextInfo:), NULL); 65 | } 66 | 67 | //撤销 68 | - (void)revoke{ 69 | if ([self.paintingImageView hp_hasStocks]) { 70 | [self.paintingImageView hp_undo]; 71 | } 72 | } 73 | 74 | - (void)changeColor{ 75 | UIColor *color = [UIColor colorWithRed:arc4random() % 255 / 255.0 green:arc4random() % 255 / 255.0 blue:arc4random() % 255 / 255.0 alpha:1]; 76 | [self.paintingImageView hp_chooseWithColor:color abstractScale:self.backGroundScrollerView.zoomScale]; 77 | } 78 | 79 | //保存至相册 80 | - (void)resultImage:(UIImage *)resultImage didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{ 81 | NSLog(@"save error : %@",error); 82 | } 83 | 84 | #pragma mark - UIScrollViewDelegate 85 | 86 | - (nullable UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { 87 | return self.paintingImageView; 88 | } 89 | 90 | - (void)scrollViewDidZoom:(UIScrollView *)scrollView { 91 | [self adjustPictureImageViewScrollFrame]; 92 | [self layoutPaintLayer]; 93 | } 94 | 95 | /** 96 | 重新设置手绘放大倍数 97 | */ 98 | - (void)layoutPaintLayer{ 99 | [self.paintingImageView hp_setAbsoluteScale:self.backGroundScrollerView.zoomScale]; 100 | } 101 | 102 | 103 | /** 104 | 调整pictureImageView位置边界 105 | */ 106 | - (void)adjustPictureImageViewScrollFrame{ 107 | 108 | CGSize scrollerBoundsSize = self.backGroundScrollerView.bounds.size; 109 | 110 | CGRect imageViewframe = self.paintingImageView.frame; 111 | 112 | if (imageViewframe.size.width > scrollerBoundsSize.width) { 113 | //图宽大于屏宽 114 | imageViewframe.origin.x = 0; 115 | if (!CGRectEqualToRect(self.paintingImageView.frame, imageViewframe)) 116 | self.paintingImageView.frame = imageViewframe; 117 | }else{ 118 | //图宽小于屏宽 119 | self.paintingImageView.center = CGPointMake(self.backGroundScrollerView.center.x, self.paintingImageView.center.y); 120 | } 121 | 122 | //使图片在缩小时保持居中显示(注意:不能改变pictureImageView.origin.y,如果改变则手绘的相对位置会改变,所以这里只改变center.y保持居中) 123 | if (imageViewframe.size.height <= scrollerBoundsSize.height) { 124 | self.paintingImageView.center = CGPointMake(self.paintingImageView.center.x, self.backGroundScrollerView.center.y); 125 | } 126 | 127 | [self.backGroundScrollerView setContentInset:UIEdgeInsetsZero]; 128 | [self.backGroundScrollerView setContentSize:CGSizeMake(imageViewframe.size.width, imageViewframe.size.height)]; 129 | } 130 | 131 | 132 | /** 133 | 设置ScrollerView缩放比 134 | */ 135 | - (void)setMaxMinZoomScalesForCurrentBounds { 136 | 137 | // Sizes 138 | CGSize boundsSize = self.backGroundScrollerView.bounds.size; 139 | CGSize imageSize = self.paintingImageView.frame.size; 140 | 141 | /**Scale逻辑: 142 | 1.理解:若图尺寸大,则scale < 1 需要缩小,所以选择scroller.size / imageSize; 143 | 2.获取最小缩放比:宽高之比,取最小值即可作为最小缩放比; 144 | 3.获取当前的缩放比,保证"恰好"铺满全屏:宽之比与高之比都需要判断,因为要"恰好"铺满全屏展示,所以需要选择二者中最短边对应的缩放比作为currentScale,保证最短的边"恰好"铺满全屏. 145 | 若 scale都 < 1 都需要缩小 -> 则选择数值最大的 , 若 scale都 > 1 都需要放大 -> 则选择数值最大的 若有的边 scale < 1 有的 > 1 则选择数值大的,保证铺满全屏; 146 | 4.最大缩放比:只要保证最大缩放比比最小缩放比和当前缩放比大即可,若最大缩放比小于当前缩放比,则系统会默认最大缩放比为当前缩放比 147 | */ 148 | CGFloat xScale = (CGFloat)boundsSize.width / imageSize.width; 149 | CGFloat yScale = (CGFloat)boundsSize.height / imageSize.height; 150 | 151 | CGFloat minScale = MIN(xScale, yScale);//取最小倍数作为 scrollerView的最小缩放倍数 152 | CGFloat currentScale = MAX(xScale, yScale); 153 | CGFloat maxScale = minScale * 4 < currentScale ? currentScale * 2 : minScale * 4; 154 | 155 | self.backGroundScrollerView.maximumZoomScale = maxScale; 156 | self.backGroundScrollerView.minimumZoomScale = minScale; 157 | self.backGroundScrollerView.zoomScale = currentScale; 158 | 159 | [self adjustPictureImageViewScrollFrame]; 160 | } 161 | 162 | 163 | #pragma mark - getter/setter 164 | 165 | - (UIImageView *)paintingImageView { 166 | if (!_paintingImageView) { 167 | UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"WechatIMG" ofType:@"jpeg"]]; 168 | NSAssert(image,@"必须有图片"); 169 | CGSize imageSize = image.size; 170 | CGFloat width = [UIScreen mainScreen].bounds.size.width; 171 | CGFloat height = imageSize.height / imageSize.width * width; 172 | _paintingImageView = [[HandPaintingImageView alloc] initWithFrame:CGRectMake(0, 0, width, height)]; 173 | _paintingImageView.image = image; 174 | [_paintingImageView hp_initWidthInMM:2.5]; 175 | [_paintingImageView hp_chooseWithColor:[UIColor blueColor] abstractScale:self.backGroundScrollerView.zoomScale]; 176 | } 177 | return _paintingImageView; 178 | } 179 | 180 | - (UIScrollView *)backGroundScrollerView { 181 | if (!_backGroundScrollerView) { 182 | _backGroundScrollerView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; 183 | _backGroundScrollerView.backgroundColor = [UIColor whiteColor]; 184 | _backGroundScrollerView.delegate = self; 185 | _backGroundScrollerView.showsHorizontalScrollIndicator = NO; 186 | _backGroundScrollerView.showsVerticalScrollIndicator = NO; 187 | _backGroundScrollerView.delaysContentTouches = false; 188 | _backGroundScrollerView.decelerationRate = UIScrollViewDecelerationRateFast; 189 | _backGroundScrollerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 190 | [_backGroundScrollerView addSubview:self.paintingImageView]; 191 | _backGroundScrollerView.panGestureRecognizer.minimumNumberOfTouches = 2; 192 | [self.view addSubview:_backGroundScrollerView]; 193 | } 194 | return _backGroundScrollerView; 195 | } 196 | 197 | - (void)didReceiveMemoryWarning { 198 | [super didReceiveMemoryWarning]; 199 | 200 | } 201 | 202 | @end 203 | -------------------------------------------------------------------------------- /ERHandPainting/HandPainting/HandPaintingImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // HandPaintingImageView.m 3 | // ErHuDemo 4 | // 5 | // Created by 胡广宇 on 2017/6/2. 6 | // Copyright © 2017年 胡广宇. All rights reserved. 7 | // 8 | 9 | #import "HandPaintingImageView.h" 10 | #import "Stroke.h" 11 | 12 | #ifndef nob_defer_h 13 | #define nob_defer_h 14 | 15 | // some helper declarations 16 | #define _nob_macro_concat(a, b) a##b 17 | #define nob_macro_concat(a, b) _nob_macro_concat(a, b) 18 | typedef void(^nob_defer_block_t)(); 19 | NS_INLINE void nob_deferFunc(__strong nob_defer_block_t *blockRef) 20 | { 21 | nob_defer_block_t actualBlock = *blockRef; 22 | actualBlock(); 23 | } 24 | 25 | // the core macro 26 | #define nob_defer(deferBlock) \ 27 | __strong nob_defer_block_t nob_macro_concat(__nob_stack_defer_block_, __LINE__) __attribute__((cleanup(nob_deferFunc), unused)) = deferBlock 28 | 29 | #endif /* nob_defer_h */ 30 | 31 | @interface PanWithStartGestureRecognizer : UIPanGestureRecognizer 32 | // 开始点击的点位 33 | @property (nonatomic, assign) CGPoint start; 34 | // 拖动后的点位 35 | @property (nonatomic, assign) CGPoint point; 36 | 37 | @end 38 | 39 | @implementation PanWithStartGestureRecognizer 40 | 41 | @end 42 | 43 | @interface TapWithStartGestureRecognizer : UITapGestureRecognizer 44 | // 开始点击的点位 45 | @property (nonatomic, assign) CGPoint start; 46 | 47 | @end 48 | 49 | @implementation TapWithStartGestureRecognizer 50 | 51 | @end 52 | 53 | @interface HandPainting : NSObject 54 | 55 | @property (nonatomic, strong) NSMutableArray* redoList; 56 | 57 | @property (nonatomic, strong) NSMutableArray* strokes; 58 | 59 | @property (nonatomic, strong) PanWithStartGestureRecognizer *pan; 60 | 61 | @property (nonatomic, strong) TapWithStartGestureRecognizer *tap; 62 | 63 | @property (nonatomic, strong) UIImageView *imageView; 64 | 65 | @property (nonatomic, assign) double widthInMM; 66 | 67 | @property (nonatomic, strong) Stroke *currentStroke; 68 | 69 | @property (nonatomic, strong) CALayer *drawLayer; 70 | 71 | @property (nonatomic, strong) UIColor *currColor; 72 | 73 | @property (nonatomic, assign) CGFloat currScale; 74 | 75 | @property (nonatomic, assign) CGFloat abstractScale; 76 | 77 | 78 | - (instancetype)initWithImageView:(UIImageView *)imageView widthInMM:(double)widthInMM; 79 | 80 | @end 81 | 82 | @implementation HandPainting 83 | 84 | - (instancetype)initWithImageView:(UIImageView *)imageView widthInMM:(double)widthInMM{ 85 | if (self = [super init]) { 86 | 87 | self.imageView = imageView; 88 | self.widthInMM = widthInMM; 89 | 90 | self.redoList = [NSMutableArray array]; 91 | self.strokes = [NSMutableArray array]; 92 | self.currColor = [UIColor redColor]; 93 | self.currScale = 1.0; 94 | self.abstractScale = 1.0; 95 | 96 | self.pan = [[PanWithStartGestureRecognizer alloc] initWithTarget:self action:@selector(dragging:)]; 97 | self.pan.maximumNumberOfTouches = 1; 98 | 99 | self.tap = [[TapWithStartGestureRecognizer alloc] initWithTarget:self action:@selector(tapping:)]; 100 | 101 | [self.tap requireGestureRecognizerToFail:self.pan]; 102 | 103 | self.pan.cancelsTouchesInView = false;//重要 104 | } 105 | return self; 106 | } 107 | 108 | #pragma mark - 行为识别回调 109 | 110 | //行为识别回调 111 | - (void)dragging:(PanWithStartGestureRecognizer *)p{ 112 | switch (p.state) { 113 | case UIGestureRecognizerStateChanged: 114 | { 115 | if (!self.currentStroke) { 116 | self.currentStroke = [[Stroke alloc] initWithColor:self.currColor width:[self mm2pt:self.widthInMM] / self.currScale / self.abstractScale]; 117 | } 118 | 119 | if (!self.currentStroke.points.count) { 120 | // 将所画点的坐标按比例缩放 121 | CGPoint np = [self.drawLayer convertPoint:p.start fromLayer:self.imageView.layer]; 122 | [self.currentStroke pass:CGPointMake(np.x / self.currScale, np.y / self.currScale)]; 123 | } 124 | 125 | CGPoint np = [self.drawLayer convertPoint:p.point fromLayer:self.imageView.layer]; 126 | // 将所画点的坐标按比例缩放 127 | [self.currentStroke pass:CGPointMake(np.x / self.currScale, np.y / self.currScale)]; 128 | [self.drawLayer setNeedsDisplay]; 129 | } 130 | break; 131 | case UIGestureRecognizerStateEnded: 132 | case UIGestureRecognizerStateCancelled: 133 | { 134 | if (!self.currentStroke) { 135 | self.currentStroke = [[Stroke alloc] initWithColor:self.currColor width:[self mm2pt:self.widthInMM] / self.currScale / self.abstractScale]; 136 | } 137 | // 无论是结束还是取消, 都算绘制成功 138 | CGPoint np = [self.drawLayer convertPoint:p.point fromLayer:self.imageView.layer]; 139 | [self.currentStroke pass:CGPointMake(np.x / self.currScale, np.y / self.currScale)]; 140 | [self.strokes addObject:self.currentStroke]; 141 | self.currentStroke = nil; 142 | [self.drawLayer setNeedsDisplay]; 143 | } 144 | break; 145 | default: 146 | break; 147 | } 148 | } 149 | 150 | - (void)tapping:(TapWithStartGestureRecognizer *)p{ 151 | switch (p.state) { 152 | case UIGestureRecognizerStateEnded: 153 | { 154 | if (!self.currentStroke) { 155 | self.currentStroke = [[Stroke alloc] initWithColor:self.currColor width:[self mm2pt:self.widthInMM] / self.currScale / self.abstractScale]; 156 | } 157 | CGPoint np = [self.drawLayer convertPoint:p.start fromLayer:self.imageView.layer]; 158 | [self.currentStroke pass:CGPointMake(np.x / self.currScale, np.y / self.currScale)]; 159 | [self.strokes addObject:self.currentStroke]; 160 | self.currentStroke = nil; 161 | [self.drawLayer setNeedsDisplay]; 162 | } 163 | break; 164 | default: 165 | break; 166 | } 167 | } 168 | 169 | 170 | - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{ 171 | UIGraphicsPushContext(ctx); 172 | 173 | nob_defer(^{ 174 | UIGraphicsPopContext(); 175 | }); 176 | 177 | CGContextScaleCTM(ctx, self.currScale, self.currScale); 178 | [self drawStockes]; 179 | } 180 | 181 | - (void)drawStockes{ 182 | [self drawInit]; 183 | for (Stroke *storke in self.strokes) { 184 | [storke draw]; 185 | } 186 | 187 | if (self.currentStroke && self.currentStroke.points.count) { 188 | [self.currentStroke draw]; 189 | } 190 | } 191 | 192 | - (void)drawInit{ 193 | CGContextRef context = UIGraphicsGetCurrentContext(); 194 | if (context) { 195 | CGContextSetAllowsAntialiasing(context, true); 196 | CGContextSetShouldAntialias(context, true); 197 | CGContextSetAllowsFontSmoothing(context, true); 198 | CGContextSetShouldSmoothFonts(context, true); 199 | } 200 | } 201 | 202 | - (void)reset4Painting{ 203 | CGFloat width = self.imageView.image.size.width; 204 | CGFloat height = self.imageView.image.size.height; 205 | 206 | // 检测纵向填满 207 | CGFloat newHeight = self.imageView.layer.bounds.size.height; 208 | CGFloat newWidth = width * self.imageView.layer.bounds.size.height / height; 209 | 210 | if (newWidth > self.imageView.layer.bounds.size.width) { 211 | // 检测横向填满 212 | newHeight = height * self.imageView.layer.bounds.size.width / width; 213 | newWidth = self.imageView.layer.bounds.size.width; 214 | } 215 | 216 | self.currScale = newWidth / width; 217 | 218 | [self skipAnimation:^{ 219 | self.drawLayer.contentsScale = self.abstractScale * [UIScreen mainScreen].scale; 220 | self.drawLayer.position = CGPointMake(CGRectGetMidX(self.imageView.layer.bounds), CGRectGetMidY(self.imageView.layer.bounds)); 221 | self.drawLayer.bounds = CGRectMake(0, 0, newWidth, newHeight); 222 | }]; 223 | [self.drawLayer setNeedsDisplay]; 224 | } 225 | 226 | - (void)setAbsoluteScale:(CGFloat)scale{ 227 | self.abstractScale = scale; 228 | } 229 | 230 | #pragma mark - 扩展方法 231 | 232 | //毫米转PT 233 | - (CGFloat)mm2pt:(double)mm{ 234 | 235 | /// 英寸比毫米 236 | static CGFloat MM_PER_IN = 25.4; 237 | /// PT比英寸 238 | static CGFloat PT_PRE_IN = 72.0; 239 | 240 | return (mm / MM_PER_IN * PT_PRE_IN); 241 | } 242 | 243 | - (void)skipAnimation:(void (^)())completion{ 244 | [CATransaction begin]; 245 | nob_defer(^{ 246 | [CATransaction commit]; 247 | }); 248 | [CATransaction setDisableActions:true]; 249 | if (completion) { 250 | completion(); 251 | } 252 | } 253 | 254 | @end 255 | 256 | @interface HandPaintingImageView () 257 | 258 | @property (nonatomic, strong) HandPainting *handPating; 259 | 260 | @end 261 | 262 | @implementation HandPaintingImageView 263 | 264 | - (void)hp_initWidthInMM:(double)widthInMM{ 265 | 266 | self.userInteractionEnabled = true; 267 | self.clipsToBounds = true; 268 | 269 | self.handPating = [[HandPainting alloc] initWithImageView:self widthInMM:widthInMM]; 270 | CALayer *drawLayer = [[CALayer alloc] init]; 271 | drawLayer.delegate = self.handPating; 272 | self.handPating.drawLayer = drawLayer; 273 | [self.layer addSublayer:self.handPating.drawLayer]; 274 | [self.handPating reset4Painting]; 275 | } 276 | 277 | // 进入绘图页面时选中某种颜色 278 | - (void)hp_chooseWithColor:(UIColor *)color abstractScale:(CGFloat)abstractScale{ 279 | if (self.handPating) { 280 | [self removeGestureRecognizer:self.handPating.pan]; 281 | [self removeGestureRecognizer:self.handPating.tap]; 282 | [self addGestureRecognizer:self.handPating.pan]; 283 | [self addGestureRecognizer:self.handPating.tap]; 284 | self.handPating.currColor = color; 285 | [self.handPating setAbsoluteScale:abstractScale]; 286 | } 287 | } 288 | // 离开绘图页面时取消选中某种颜色 289 | - (void)hp_unchoose{ 290 | if (self.handPating) { 291 | [self removeGestureRecognizer:self.handPating.pan]; 292 | [self removeGestureRecognizer:self.handPating.tap]; 293 | } 294 | } 295 | 296 | // 撤销绘图 297 | - (void)hp_undo{ 298 | if (self.handPating && self.handPating.strokes.count) { 299 | [self.handPating.redoList addObject:self.handPating.strokes.lastObject]; 300 | [self.handPating.strokes removeLastObject]; 301 | [self.handPating reset4Painting]; 302 | } 303 | } 304 | // 是否进行过标注 305 | - (BOOL)hp_hasStocks{ 306 | return self.handPating && self.handPating.strokes.count; 307 | } 308 | 309 | // 标注过的图片需要通过此方法将标注与原图混合 310 | - (void)hp_drawOnImage{ 311 | if (self.handPating && self.handPating.strokes.count){ 312 | CGSize size = CGSizeMake(self.image.size.width, self.image.size.height); 313 | UIImage *flipImage = [self flip:self.image.CGImage size:size opaque:true scale:1]; 314 | self.image = [self imageOf:size opaque:true scale:1 completion:^{ 315 | CGContextRef context = UIGraphicsGetCurrentContext(); 316 | CGContextDrawImage(context, CGRectMake(0, 0, size.width, size.height), flipImage.CGImage); 317 | [self.handPating drawStockes]; 318 | }]; 319 | [self.handPating.strokes removeAllObjects]; 320 | [self.handPating reset4Painting]; 321 | } 322 | } 323 | 324 | // 重新计算缩放比等绘制参数 325 | - (void)hp_reset4Painting{ 326 | if (self.handPating) { 327 | [self.handPating reset4Painting]; 328 | } 329 | } 330 | 331 | // 传入绝对的缩放比 332 | - (void)hp_setAbsoluteScale:(CGFloat)scale{ 333 | if (self.handPating) { 334 | [self.handPating setAbsoluteScale:scale]; 335 | } 336 | } 337 | 338 | - (void)layoutSublayersOfLayer:(CALayer *)layer{ 339 | [self hp_reset4Painting]; 340 | [super layoutSublayersOfLayer:layer]; 341 | } 342 | 343 | 344 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 345 | [super touchesBegan:touches withEvent:event]; 346 | 347 | self.handPating.pan.start = [self.handPating.pan locationInView:self]; 348 | self.handPating.pan.point = self.handPating.pan.start; 349 | 350 | self.handPating.tap.start = [self.handPating.tap locationInView:self]; 351 | } 352 | 353 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 354 | [super touchesMoved:touches withEvent:event]; 355 | self.handPating.pan.point = [self.handPating.pan locationInView:self]; 356 | } 357 | 358 | 359 | - (UIImage *)imageOf:(CGSize)size opaque:(BOOL)opaque scale:(CGFloat)scale completion:(void (^)())completion{ 360 | if ([[UIDevice currentDevice].systemVersion floatValue] > 10) { 361 | UIGraphicsImageRendererFormat *f = [UIGraphicsImageRendererFormat defaultFormat]; 362 | f.opaque = opaque; 363 | if (scale > 0) { 364 | f.scale = scale; 365 | } 366 | UIGraphicsImageRenderer *r = [[UIGraphicsImageRenderer alloc] initWithSize:size format:f]; 367 | return [r imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) { 368 | if (completion) { 369 | completion(); 370 | } 371 | }]; 372 | }else{ 373 | UIGraphicsBeginImageContextWithOptions(size, opaque, scale); 374 | nob_defer(^{ 375 | UIGraphicsEndImageContext(); 376 | }); 377 | if (completion) { 378 | completion(); 379 | } 380 | return UIGraphicsGetImageFromCurrentImageContext(); 381 | } 382 | } 383 | 384 | - (UIImage *)flip:(CGImageRef)im size:(CGSize)size opaque:(BOOL)opaque scale:(CGFloat)scale{ 385 | return [self imageOf:size opaque:opaque scale:scale completion:^{ 386 | CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, size.width, size.height), im); 387 | }]; 388 | } 389 | @end 390 | -------------------------------------------------------------------------------- /ERHandPainting.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D85CD3DA1F13157100CE5640 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D85CD3D91F13157100CE5640 /* main.m */; }; 11 | D85CD3DD1F13157100CE5640 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D85CD3DC1F13157100CE5640 /* AppDelegate.m */; }; 12 | D85CD3E31F13157100CE5640 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D85CD3E11F13157100CE5640 /* Main.storyboard */; }; 13 | D85CD3E51F13157100CE5640 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D85CD3E41F13157100CE5640 /* Assets.xcassets */; }; 14 | D85CD3E81F13157100CE5640 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D85CD3E61F13157100CE5640 /* LaunchScreen.storyboard */; }; 15 | D85CD3F31F13157100CE5640 /* ERHandPaintingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D85CD3F21F13157100CE5640 /* ERHandPaintingTests.m */; }; 16 | D85CD3FE1F13157100CE5640 /* ERHandPaintingUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = D85CD3FD1F13157100CE5640 /* ERHandPaintingUITests.m */; }; 17 | D85CD4101F13159C00CE5640 /* HandPaintingImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D85CD40D1F13159C00CE5640 /* HandPaintingImageView.m */; }; 18 | D85CD4111F13159C00CE5640 /* Stroke.m in Sources */ = {isa = PBXBuildFile; fileRef = D85CD40F1F13159C00CE5640 /* Stroke.m */; }; 19 | D85CD4141F1315C600CE5640 /* HandPaintViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D85CD4131F1315C600CE5640 /* HandPaintViewController.m */; }; 20 | D85CD4161F1317C600CE5640 /* WechatIMG.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = D85CD4151F1317C600CE5640 /* WechatIMG.jpeg */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | D85CD3EF1F13157100CE5640 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = D85CD3CD1F13157100CE5640 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = D85CD3D41F13157100CE5640; 29 | remoteInfo = ERHandPainting; 30 | }; 31 | D85CD3FA1F13157100CE5640 /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = D85CD3CD1F13157100CE5640 /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = D85CD3D41F13157100CE5640; 36 | remoteInfo = ERHandPainting; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | D85CD3D51F13157100CE5640 /* ERHandPainting.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ERHandPainting.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | D85CD3D91F13157100CE5640 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | D85CD3DB1F13157100CE5640 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | D85CD3DC1F13157100CE5640 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | D85CD3E21F13157100CE5640 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | D85CD3E41F13157100CE5640 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | D85CD3E71F13157100CE5640 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | D85CD3E91F13157100CE5640 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | D85CD3EE1F13157100CE5640 /* ERHandPaintingTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ERHandPaintingTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | D85CD3F21F13157100CE5640 /* ERHandPaintingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ERHandPaintingTests.m; sourceTree = ""; }; 51 | D85CD3F41F13157100CE5640 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | D85CD3F91F13157100CE5640 /* ERHandPaintingUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ERHandPaintingUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | D85CD3FD1F13157100CE5640 /* ERHandPaintingUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ERHandPaintingUITests.m; sourceTree = ""; }; 54 | D85CD3FF1F13157100CE5640 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | D85CD40C1F13159C00CE5640 /* HandPaintingImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HandPaintingImageView.h; sourceTree = ""; }; 56 | D85CD40D1F13159C00CE5640 /* HandPaintingImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HandPaintingImageView.m; sourceTree = ""; }; 57 | D85CD40E1F13159C00CE5640 /* Stroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Stroke.h; sourceTree = ""; }; 58 | D85CD40F1F13159C00CE5640 /* Stroke.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Stroke.m; sourceTree = ""; }; 59 | D85CD4121F1315C600CE5640 /* HandPaintViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HandPaintViewController.h; sourceTree = ""; }; 60 | D85CD4131F1315C600CE5640 /* HandPaintViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HandPaintViewController.m; sourceTree = ""; }; 61 | D85CD4151F1317C600CE5640 /* WechatIMG.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = WechatIMG.jpeg; sourceTree = ""; }; 62 | /* End PBXFileReference section */ 63 | 64 | /* Begin PBXFrameworksBuildPhase section */ 65 | D85CD3D21F13157100CE5640 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | D85CD3EB1F13157100CE5640 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | D85CD3F61F13157100CE5640 /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | }; 86 | /* End PBXFrameworksBuildPhase section */ 87 | 88 | /* Begin PBXGroup section */ 89 | D85CD3CC1F13157100CE5640 = { 90 | isa = PBXGroup; 91 | children = ( 92 | D85CD3D71F13157100CE5640 /* ERHandPainting */, 93 | D85CD3F11F13157100CE5640 /* ERHandPaintingTests */, 94 | D85CD3FC1F13157100CE5640 /* ERHandPaintingUITests */, 95 | D85CD3D61F13157100CE5640 /* Products */, 96 | ); 97 | sourceTree = ""; 98 | }; 99 | D85CD3D61F13157100CE5640 /* Products */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | D85CD3D51F13157100CE5640 /* ERHandPainting.app */, 103 | D85CD3EE1F13157100CE5640 /* ERHandPaintingTests.xctest */, 104 | D85CD3F91F13157100CE5640 /* ERHandPaintingUITests.xctest */, 105 | ); 106 | name = Products; 107 | sourceTree = ""; 108 | }; 109 | D85CD3D71F13157100CE5640 /* ERHandPainting */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | D85CD40B1F13159C00CE5640 /* HandPainting */, 113 | D85CD3DB1F13157100CE5640 /* AppDelegate.h */, 114 | D85CD3DC1F13157100CE5640 /* AppDelegate.m */, 115 | D85CD4121F1315C600CE5640 /* HandPaintViewController.h */, 116 | D85CD4131F1315C600CE5640 /* HandPaintViewController.m */, 117 | D85CD4151F1317C600CE5640 /* WechatIMG.jpeg */, 118 | D85CD3E11F13157100CE5640 /* Main.storyboard */, 119 | D85CD3E41F13157100CE5640 /* Assets.xcassets */, 120 | D85CD3E61F13157100CE5640 /* LaunchScreen.storyboard */, 121 | D85CD3E91F13157100CE5640 /* Info.plist */, 122 | D85CD3D81F13157100CE5640 /* Supporting Files */, 123 | ); 124 | path = ERHandPainting; 125 | sourceTree = ""; 126 | }; 127 | D85CD3D81F13157100CE5640 /* Supporting Files */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | D85CD3D91F13157100CE5640 /* main.m */, 131 | ); 132 | name = "Supporting Files"; 133 | sourceTree = ""; 134 | }; 135 | D85CD3F11F13157100CE5640 /* ERHandPaintingTests */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | D85CD3F21F13157100CE5640 /* ERHandPaintingTests.m */, 139 | D85CD3F41F13157100CE5640 /* Info.plist */, 140 | ); 141 | path = ERHandPaintingTests; 142 | sourceTree = ""; 143 | }; 144 | D85CD3FC1F13157100CE5640 /* ERHandPaintingUITests */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | D85CD3FD1F13157100CE5640 /* ERHandPaintingUITests.m */, 148 | D85CD3FF1F13157100CE5640 /* Info.plist */, 149 | ); 150 | path = ERHandPaintingUITests; 151 | sourceTree = ""; 152 | }; 153 | D85CD40B1F13159C00CE5640 /* HandPainting */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | D85CD40C1F13159C00CE5640 /* HandPaintingImageView.h */, 157 | D85CD40D1F13159C00CE5640 /* HandPaintingImageView.m */, 158 | D85CD40E1F13159C00CE5640 /* Stroke.h */, 159 | D85CD40F1F13159C00CE5640 /* Stroke.m */, 160 | ); 161 | path = HandPainting; 162 | sourceTree = ""; 163 | }; 164 | /* End PBXGroup section */ 165 | 166 | /* Begin PBXNativeTarget section */ 167 | D85CD3D41F13157100CE5640 /* ERHandPainting */ = { 168 | isa = PBXNativeTarget; 169 | buildConfigurationList = D85CD4021F13157100CE5640 /* Build configuration list for PBXNativeTarget "ERHandPainting" */; 170 | buildPhases = ( 171 | D85CD3D11F13157100CE5640 /* Sources */, 172 | D85CD3D21F13157100CE5640 /* Frameworks */, 173 | D85CD3D31F13157100CE5640 /* Resources */, 174 | ); 175 | buildRules = ( 176 | ); 177 | dependencies = ( 178 | ); 179 | name = ERHandPainting; 180 | productName = ERHandPainting; 181 | productReference = D85CD3D51F13157100CE5640 /* ERHandPainting.app */; 182 | productType = "com.apple.product-type.application"; 183 | }; 184 | D85CD3ED1F13157100CE5640 /* ERHandPaintingTests */ = { 185 | isa = PBXNativeTarget; 186 | buildConfigurationList = D85CD4051F13157100CE5640 /* Build configuration list for PBXNativeTarget "ERHandPaintingTests" */; 187 | buildPhases = ( 188 | D85CD3EA1F13157100CE5640 /* Sources */, 189 | D85CD3EB1F13157100CE5640 /* Frameworks */, 190 | D85CD3EC1F13157100CE5640 /* Resources */, 191 | ); 192 | buildRules = ( 193 | ); 194 | dependencies = ( 195 | D85CD3F01F13157100CE5640 /* PBXTargetDependency */, 196 | ); 197 | name = ERHandPaintingTests; 198 | productName = ERHandPaintingTests; 199 | productReference = D85CD3EE1F13157100CE5640 /* ERHandPaintingTests.xctest */; 200 | productType = "com.apple.product-type.bundle.unit-test"; 201 | }; 202 | D85CD3F81F13157100CE5640 /* ERHandPaintingUITests */ = { 203 | isa = PBXNativeTarget; 204 | buildConfigurationList = D85CD4081F13157100CE5640 /* Build configuration list for PBXNativeTarget "ERHandPaintingUITests" */; 205 | buildPhases = ( 206 | D85CD3F51F13157100CE5640 /* Sources */, 207 | D85CD3F61F13157100CE5640 /* Frameworks */, 208 | D85CD3F71F13157100CE5640 /* Resources */, 209 | ); 210 | buildRules = ( 211 | ); 212 | dependencies = ( 213 | D85CD3FB1F13157100CE5640 /* PBXTargetDependency */, 214 | ); 215 | name = ERHandPaintingUITests; 216 | productName = ERHandPaintingUITests; 217 | productReference = D85CD3F91F13157100CE5640 /* ERHandPaintingUITests.xctest */; 218 | productType = "com.apple.product-type.bundle.ui-testing"; 219 | }; 220 | /* End PBXNativeTarget section */ 221 | 222 | /* Begin PBXProject section */ 223 | D85CD3CD1F13157100CE5640 /* Project object */ = { 224 | isa = PBXProject; 225 | attributes = { 226 | LastUpgradeCheck = 0830; 227 | ORGANIZATIONNAME = "胡广宇"; 228 | TargetAttributes = { 229 | D85CD3D41F13157100CE5640 = { 230 | CreatedOnToolsVersion = 8.3.3; 231 | DevelopmentTeam = 7W6345K7JN; 232 | ProvisioningStyle = Automatic; 233 | }; 234 | D85CD3ED1F13157100CE5640 = { 235 | CreatedOnToolsVersion = 8.3.3; 236 | DevelopmentTeam = 7W6345K7JN; 237 | ProvisioningStyle = Automatic; 238 | TestTargetID = D85CD3D41F13157100CE5640; 239 | }; 240 | D85CD3F81F13157100CE5640 = { 241 | CreatedOnToolsVersion = 8.3.3; 242 | DevelopmentTeam = 7W6345K7JN; 243 | ProvisioningStyle = Automatic; 244 | TestTargetID = D85CD3D41F13157100CE5640; 245 | }; 246 | }; 247 | }; 248 | buildConfigurationList = D85CD3D01F13157100CE5640 /* Build configuration list for PBXProject "ERHandPainting" */; 249 | compatibilityVersion = "Xcode 3.2"; 250 | developmentRegion = English; 251 | hasScannedForEncodings = 0; 252 | knownRegions = ( 253 | en, 254 | Base, 255 | ); 256 | mainGroup = D85CD3CC1F13157100CE5640; 257 | productRefGroup = D85CD3D61F13157100CE5640 /* Products */; 258 | projectDirPath = ""; 259 | projectRoot = ""; 260 | targets = ( 261 | D85CD3D41F13157100CE5640 /* ERHandPainting */, 262 | D85CD3ED1F13157100CE5640 /* ERHandPaintingTests */, 263 | D85CD3F81F13157100CE5640 /* ERHandPaintingUITests */, 264 | ); 265 | }; 266 | /* End PBXProject section */ 267 | 268 | /* Begin PBXResourcesBuildPhase section */ 269 | D85CD3D31F13157100CE5640 /* Resources */ = { 270 | isa = PBXResourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | D85CD3E81F13157100CE5640 /* LaunchScreen.storyboard in Resources */, 274 | D85CD3E51F13157100CE5640 /* Assets.xcassets in Resources */, 275 | D85CD3E31F13157100CE5640 /* Main.storyboard in Resources */, 276 | D85CD4161F1317C600CE5640 /* WechatIMG.jpeg in Resources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | D85CD3EC1F13157100CE5640 /* Resources */ = { 281 | isa = PBXResourcesBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | D85CD3F71F13157100CE5640 /* Resources */ = { 288 | isa = PBXResourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | ); 292 | runOnlyForDeploymentPostprocessing = 0; 293 | }; 294 | /* End PBXResourcesBuildPhase section */ 295 | 296 | /* Begin PBXSourcesBuildPhase section */ 297 | D85CD3D11F13157100CE5640 /* Sources */ = { 298 | isa = PBXSourcesBuildPhase; 299 | buildActionMask = 2147483647; 300 | files = ( 301 | D85CD4111F13159C00CE5640 /* Stroke.m in Sources */, 302 | D85CD4101F13159C00CE5640 /* HandPaintingImageView.m in Sources */, 303 | D85CD3DD1F13157100CE5640 /* AppDelegate.m in Sources */, 304 | D85CD4141F1315C600CE5640 /* HandPaintViewController.m in Sources */, 305 | D85CD3DA1F13157100CE5640 /* main.m in Sources */, 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | }; 309 | D85CD3EA1F13157100CE5640 /* Sources */ = { 310 | isa = PBXSourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | D85CD3F31F13157100CE5640 /* ERHandPaintingTests.m in Sources */, 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | }; 317 | D85CD3F51F13157100CE5640 /* Sources */ = { 318 | isa = PBXSourcesBuildPhase; 319 | buildActionMask = 2147483647; 320 | files = ( 321 | D85CD3FE1F13157100CE5640 /* ERHandPaintingUITests.m in Sources */, 322 | ); 323 | runOnlyForDeploymentPostprocessing = 0; 324 | }; 325 | /* End PBXSourcesBuildPhase section */ 326 | 327 | /* Begin PBXTargetDependency section */ 328 | D85CD3F01F13157100CE5640 /* PBXTargetDependency */ = { 329 | isa = PBXTargetDependency; 330 | target = D85CD3D41F13157100CE5640 /* ERHandPainting */; 331 | targetProxy = D85CD3EF1F13157100CE5640 /* PBXContainerItemProxy */; 332 | }; 333 | D85CD3FB1F13157100CE5640 /* PBXTargetDependency */ = { 334 | isa = PBXTargetDependency; 335 | target = D85CD3D41F13157100CE5640 /* ERHandPainting */; 336 | targetProxy = D85CD3FA1F13157100CE5640 /* PBXContainerItemProxy */; 337 | }; 338 | /* End PBXTargetDependency section */ 339 | 340 | /* Begin PBXVariantGroup section */ 341 | D85CD3E11F13157100CE5640 /* Main.storyboard */ = { 342 | isa = PBXVariantGroup; 343 | children = ( 344 | D85CD3E21F13157100CE5640 /* Base */, 345 | ); 346 | name = Main.storyboard; 347 | sourceTree = ""; 348 | }; 349 | D85CD3E61F13157100CE5640 /* LaunchScreen.storyboard */ = { 350 | isa = PBXVariantGroup; 351 | children = ( 352 | D85CD3E71F13157100CE5640 /* Base */, 353 | ); 354 | name = LaunchScreen.storyboard; 355 | sourceTree = ""; 356 | }; 357 | /* End PBXVariantGroup section */ 358 | 359 | /* Begin XCBuildConfiguration section */ 360 | D85CD4001F13157100CE5640 /* Debug */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | ALWAYS_SEARCH_USER_PATHS = NO; 364 | CLANG_ANALYZER_NONNULL = YES; 365 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 366 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 367 | CLANG_CXX_LIBRARY = "libc++"; 368 | CLANG_ENABLE_MODULES = YES; 369 | CLANG_ENABLE_OBJC_ARC = YES; 370 | CLANG_WARN_BOOL_CONVERSION = YES; 371 | CLANG_WARN_CONSTANT_CONVERSION = YES; 372 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 373 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 374 | CLANG_WARN_EMPTY_BODY = YES; 375 | CLANG_WARN_ENUM_CONVERSION = YES; 376 | CLANG_WARN_INFINITE_RECURSION = YES; 377 | CLANG_WARN_INT_CONVERSION = YES; 378 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 379 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 380 | CLANG_WARN_UNREACHABLE_CODE = YES; 381 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 382 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 383 | COPY_PHASE_STRIP = NO; 384 | DEBUG_INFORMATION_FORMAT = dwarf; 385 | ENABLE_STRICT_OBJC_MSGSEND = YES; 386 | ENABLE_TESTABILITY = YES; 387 | GCC_C_LANGUAGE_STANDARD = gnu99; 388 | GCC_DYNAMIC_NO_PIC = NO; 389 | GCC_NO_COMMON_BLOCKS = YES; 390 | GCC_OPTIMIZATION_LEVEL = 0; 391 | GCC_PREPROCESSOR_DEFINITIONS = ( 392 | "DEBUG=1", 393 | "$(inherited)", 394 | ); 395 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 396 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 397 | GCC_WARN_UNDECLARED_SELECTOR = YES; 398 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 399 | GCC_WARN_UNUSED_FUNCTION = YES; 400 | GCC_WARN_UNUSED_VARIABLE = YES; 401 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 402 | MTL_ENABLE_DEBUG_INFO = YES; 403 | ONLY_ACTIVE_ARCH = YES; 404 | SDKROOT = iphoneos; 405 | TARGETED_DEVICE_FAMILY = "1,2"; 406 | }; 407 | name = Debug; 408 | }; 409 | D85CD4011F13157100CE5640 /* Release */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | ALWAYS_SEARCH_USER_PATHS = NO; 413 | CLANG_ANALYZER_NONNULL = YES; 414 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 415 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 416 | CLANG_CXX_LIBRARY = "libc++"; 417 | CLANG_ENABLE_MODULES = YES; 418 | CLANG_ENABLE_OBJC_ARC = YES; 419 | CLANG_WARN_BOOL_CONVERSION = YES; 420 | CLANG_WARN_CONSTANT_CONVERSION = YES; 421 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 422 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 423 | CLANG_WARN_EMPTY_BODY = YES; 424 | CLANG_WARN_ENUM_CONVERSION = YES; 425 | CLANG_WARN_INFINITE_RECURSION = YES; 426 | CLANG_WARN_INT_CONVERSION = YES; 427 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 428 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 429 | CLANG_WARN_UNREACHABLE_CODE = YES; 430 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 431 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 432 | COPY_PHASE_STRIP = NO; 433 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 434 | ENABLE_NS_ASSERTIONS = NO; 435 | ENABLE_STRICT_OBJC_MSGSEND = YES; 436 | GCC_C_LANGUAGE_STANDARD = gnu99; 437 | GCC_NO_COMMON_BLOCKS = YES; 438 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 439 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 440 | GCC_WARN_UNDECLARED_SELECTOR = YES; 441 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 442 | GCC_WARN_UNUSED_FUNCTION = YES; 443 | GCC_WARN_UNUSED_VARIABLE = YES; 444 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 445 | MTL_ENABLE_DEBUG_INFO = NO; 446 | SDKROOT = iphoneos; 447 | TARGETED_DEVICE_FAMILY = "1,2"; 448 | VALIDATE_PRODUCT = YES; 449 | }; 450 | name = Release; 451 | }; 452 | D85CD4031F13157100CE5640 /* Debug */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 456 | DEVELOPMENT_TEAM = 7W6345K7JN; 457 | INFOPLIST_FILE = ERHandPainting/Info.plist; 458 | IPHONEOS_DEPLOYMENT_TARGET = 7; 459 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 460 | PRODUCT_BUNDLE_IDENTIFIER = com.erhu.ERHandPainting; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | }; 463 | name = Debug; 464 | }; 465 | D85CD4041F13157100CE5640 /* Release */ = { 466 | isa = XCBuildConfiguration; 467 | buildSettings = { 468 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 469 | DEVELOPMENT_TEAM = 7W6345K7JN; 470 | INFOPLIST_FILE = ERHandPainting/Info.plist; 471 | IPHONEOS_DEPLOYMENT_TARGET = 7; 472 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 473 | PRODUCT_BUNDLE_IDENTIFIER = com.erhu.ERHandPainting; 474 | PRODUCT_NAME = "$(TARGET_NAME)"; 475 | }; 476 | name = Release; 477 | }; 478 | D85CD4061F13157100CE5640 /* Debug */ = { 479 | isa = XCBuildConfiguration; 480 | buildSettings = { 481 | BUNDLE_LOADER = "$(TEST_HOST)"; 482 | DEVELOPMENT_TEAM = 7W6345K7JN; 483 | INFOPLIST_FILE = ERHandPaintingTests/Info.plist; 484 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 485 | PRODUCT_BUNDLE_IDENTIFIER = com.erhu.ERHandPaintingTests; 486 | PRODUCT_NAME = "$(TARGET_NAME)"; 487 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ERHandPainting.app/ERHandPainting"; 488 | }; 489 | name = Debug; 490 | }; 491 | D85CD4071F13157100CE5640 /* Release */ = { 492 | isa = XCBuildConfiguration; 493 | buildSettings = { 494 | BUNDLE_LOADER = "$(TEST_HOST)"; 495 | DEVELOPMENT_TEAM = 7W6345K7JN; 496 | INFOPLIST_FILE = ERHandPaintingTests/Info.plist; 497 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 498 | PRODUCT_BUNDLE_IDENTIFIER = com.erhu.ERHandPaintingTests; 499 | PRODUCT_NAME = "$(TARGET_NAME)"; 500 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ERHandPainting.app/ERHandPainting"; 501 | }; 502 | name = Release; 503 | }; 504 | D85CD4091F13157100CE5640 /* Debug */ = { 505 | isa = XCBuildConfiguration; 506 | buildSettings = { 507 | DEVELOPMENT_TEAM = 7W6345K7JN; 508 | INFOPLIST_FILE = ERHandPaintingUITests/Info.plist; 509 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 510 | PRODUCT_BUNDLE_IDENTIFIER = com.erhu.ERHandPaintingUITests; 511 | PRODUCT_NAME = "$(TARGET_NAME)"; 512 | TEST_TARGET_NAME = ERHandPainting; 513 | }; 514 | name = Debug; 515 | }; 516 | D85CD40A1F13157100CE5640 /* Release */ = { 517 | isa = XCBuildConfiguration; 518 | buildSettings = { 519 | DEVELOPMENT_TEAM = 7W6345K7JN; 520 | INFOPLIST_FILE = ERHandPaintingUITests/Info.plist; 521 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 522 | PRODUCT_BUNDLE_IDENTIFIER = com.erhu.ERHandPaintingUITests; 523 | PRODUCT_NAME = "$(TARGET_NAME)"; 524 | TEST_TARGET_NAME = ERHandPainting; 525 | }; 526 | name = Release; 527 | }; 528 | /* End XCBuildConfiguration section */ 529 | 530 | /* Begin XCConfigurationList section */ 531 | D85CD3D01F13157100CE5640 /* Build configuration list for PBXProject "ERHandPainting" */ = { 532 | isa = XCConfigurationList; 533 | buildConfigurations = ( 534 | D85CD4001F13157100CE5640 /* Debug */, 535 | D85CD4011F13157100CE5640 /* Release */, 536 | ); 537 | defaultConfigurationIsVisible = 0; 538 | defaultConfigurationName = Release; 539 | }; 540 | D85CD4021F13157100CE5640 /* Build configuration list for PBXNativeTarget "ERHandPainting" */ = { 541 | isa = XCConfigurationList; 542 | buildConfigurations = ( 543 | D85CD4031F13157100CE5640 /* Debug */, 544 | D85CD4041F13157100CE5640 /* Release */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | defaultConfigurationName = Release; 548 | }; 549 | D85CD4051F13157100CE5640 /* Build configuration list for PBXNativeTarget "ERHandPaintingTests" */ = { 550 | isa = XCConfigurationList; 551 | buildConfigurations = ( 552 | D85CD4061F13157100CE5640 /* Debug */, 553 | D85CD4071F13157100CE5640 /* Release */, 554 | ); 555 | defaultConfigurationIsVisible = 0; 556 | defaultConfigurationName = Release; 557 | }; 558 | D85CD4081F13157100CE5640 /* Build configuration list for PBXNativeTarget "ERHandPaintingUITests" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | D85CD4091F13157100CE5640 /* Debug */, 562 | D85CD40A1F13157100CE5640 /* Release */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | /* End XCConfigurationList section */ 568 | }; 569 | rootObject = D85CD3CD1F13157100CE5640 /* Project object */; 570 | } 571 | --------------------------------------------------------------------------------