├── README.md ├── SignDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── yunlong.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── yunlong.xcuserdatad │ └── xcschemes │ ├── SignDemo.xcscheme │ └── xcschememanagement.plist └── SignDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── BJTSignView.h ├── BJTSignView.m ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m /README.md: -------------------------------------------------------------------------------- 1 | # SignDemo 2 | iOS 手写签名生成图片 3 | 详见:http://blog.csdn.net/techalleyboy/article/details/73850774 4 | -------------------------------------------------------------------------------- /SignDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 50DE11181F039FB200FF4737 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 50DE11171F039FB200FF4737 /* main.m */; }; 11 | 50DE111B1F039FB200FF4737 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 50DE111A1F039FB200FF4737 /* AppDelegate.m */; }; 12 | 50DE111E1F039FB200FF4737 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 50DE111D1F039FB200FF4737 /* ViewController.m */; }; 13 | 50DE11211F039FB200FF4737 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50DE111F1F039FB200FF4737 /* Main.storyboard */; }; 14 | 50DE11231F039FB200FF4737 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50DE11221F039FB200FF4737 /* Assets.xcassets */; }; 15 | 50DE11261F039FB200FF4737 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50DE11241F039FB200FF4737 /* LaunchScreen.storyboard */; }; 16 | 50DE112F1F039FC000FF4737 /* BJTSignView.m in Sources */ = {isa = PBXBuildFile; fileRef = 50DE112E1F039FC000FF4737 /* BJTSignView.m */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 50DE11131F039FB200FF4737 /* SignDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SignDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 50DE11171F039FB200FF4737 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 22 | 50DE11191F039FB200FF4737 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 23 | 50DE111A1F039FB200FF4737 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 24 | 50DE111C1F039FB200FF4737 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 25 | 50DE111D1F039FB200FF4737 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 26 | 50DE11201F039FB200FF4737 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27 | 50DE11221F039FB200FF4737 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | 50DE11251F039FB200FF4737 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29 | 50DE11271F039FB200FF4737 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 50DE112D1F039FC000FF4737 /* BJTSignView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BJTSignView.h; sourceTree = ""; }; 31 | 50DE112E1F039FC000FF4737 /* BJTSignView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BJTSignView.m; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | 50DE11101F039FB200FF4737 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 50DE110A1F039FB200FF4737 = { 46 | isa = PBXGroup; 47 | children = ( 48 | 50DE11151F039FB200FF4737 /* SignDemo */, 49 | 50DE11141F039FB200FF4737 /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 50DE11141F039FB200FF4737 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 50DE11131F039FB200FF4737 /* SignDemo.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 50DE11151F039FB200FF4737 /* SignDemo */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 50DE112D1F039FC000FF4737 /* BJTSignView.h */, 65 | 50DE112E1F039FC000FF4737 /* BJTSignView.m */, 66 | 50DE11191F039FB200FF4737 /* AppDelegate.h */, 67 | 50DE111A1F039FB200FF4737 /* AppDelegate.m */, 68 | 50DE111C1F039FB200FF4737 /* ViewController.h */, 69 | 50DE111D1F039FB200FF4737 /* ViewController.m */, 70 | 50DE111F1F039FB200FF4737 /* Main.storyboard */, 71 | 50DE11221F039FB200FF4737 /* Assets.xcassets */, 72 | 50DE11241F039FB200FF4737 /* LaunchScreen.storyboard */, 73 | 50DE11271F039FB200FF4737 /* Info.plist */, 74 | 50DE11161F039FB200FF4737 /* Supporting Files */, 75 | ); 76 | path = SignDemo; 77 | sourceTree = ""; 78 | }; 79 | 50DE11161F039FB200FF4737 /* Supporting Files */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 50DE11171F039FB200FF4737 /* main.m */, 83 | ); 84 | name = "Supporting Files"; 85 | sourceTree = ""; 86 | }; 87 | /* End PBXGroup section */ 88 | 89 | /* Begin PBXNativeTarget section */ 90 | 50DE11121F039FB200FF4737 /* SignDemo */ = { 91 | isa = PBXNativeTarget; 92 | buildConfigurationList = 50DE112A1F039FB200FF4737 /* Build configuration list for PBXNativeTarget "SignDemo" */; 93 | buildPhases = ( 94 | 50DE110F1F039FB200FF4737 /* Sources */, 95 | 50DE11101F039FB200FF4737 /* Frameworks */, 96 | 50DE11111F039FB200FF4737 /* Resources */, 97 | ); 98 | buildRules = ( 99 | ); 100 | dependencies = ( 101 | ); 102 | name = SignDemo; 103 | productName = SignDemo; 104 | productReference = 50DE11131F039FB200FF4737 /* SignDemo.app */; 105 | productType = "com.apple.product-type.application"; 106 | }; 107 | /* End PBXNativeTarget section */ 108 | 109 | /* Begin PBXProject section */ 110 | 50DE110B1F039FB200FF4737 /* Project object */ = { 111 | isa = PBXProject; 112 | attributes = { 113 | LastUpgradeCheck = 0830; 114 | ORGANIZATIONNAME = yunlong; 115 | TargetAttributes = { 116 | 50DE11121F039FB200FF4737 = { 117 | CreatedOnToolsVersion = 8.3.2; 118 | DevelopmentTeam = ZP35X6KSCJ; 119 | ProvisioningStyle = Manual; 120 | }; 121 | }; 122 | }; 123 | buildConfigurationList = 50DE110E1F039FB200FF4737 /* Build configuration list for PBXProject "SignDemo" */; 124 | compatibilityVersion = "Xcode 3.2"; 125 | developmentRegion = English; 126 | hasScannedForEncodings = 0; 127 | knownRegions = ( 128 | en, 129 | Base, 130 | ); 131 | mainGroup = 50DE110A1F039FB200FF4737; 132 | productRefGroup = 50DE11141F039FB200FF4737 /* Products */; 133 | projectDirPath = ""; 134 | projectRoot = ""; 135 | targets = ( 136 | 50DE11121F039FB200FF4737 /* SignDemo */, 137 | ); 138 | }; 139 | /* End PBXProject section */ 140 | 141 | /* Begin PBXResourcesBuildPhase section */ 142 | 50DE11111F039FB200FF4737 /* Resources */ = { 143 | isa = PBXResourcesBuildPhase; 144 | buildActionMask = 2147483647; 145 | files = ( 146 | 50DE11261F039FB200FF4737 /* LaunchScreen.storyboard in Resources */, 147 | 50DE11231F039FB200FF4737 /* Assets.xcassets in Resources */, 148 | 50DE11211F039FB200FF4737 /* Main.storyboard in Resources */, 149 | ); 150 | runOnlyForDeploymentPostprocessing = 0; 151 | }; 152 | /* End PBXResourcesBuildPhase section */ 153 | 154 | /* Begin PBXSourcesBuildPhase section */ 155 | 50DE110F1F039FB200FF4737 /* Sources */ = { 156 | isa = PBXSourcesBuildPhase; 157 | buildActionMask = 2147483647; 158 | files = ( 159 | 50DE112F1F039FC000FF4737 /* BJTSignView.m in Sources */, 160 | 50DE111E1F039FB200FF4737 /* ViewController.m in Sources */, 161 | 50DE111B1F039FB200FF4737 /* AppDelegate.m in Sources */, 162 | 50DE11181F039FB200FF4737 /* main.m in Sources */, 163 | ); 164 | runOnlyForDeploymentPostprocessing = 0; 165 | }; 166 | /* End PBXSourcesBuildPhase section */ 167 | 168 | /* Begin PBXVariantGroup section */ 169 | 50DE111F1F039FB200FF4737 /* Main.storyboard */ = { 170 | isa = PBXVariantGroup; 171 | children = ( 172 | 50DE11201F039FB200FF4737 /* Base */, 173 | ); 174 | name = Main.storyboard; 175 | sourceTree = ""; 176 | }; 177 | 50DE11241F039FB200FF4737 /* LaunchScreen.storyboard */ = { 178 | isa = PBXVariantGroup; 179 | children = ( 180 | 50DE11251F039FB200FF4737 /* Base */, 181 | ); 182 | name = LaunchScreen.storyboard; 183 | sourceTree = ""; 184 | }; 185 | /* End PBXVariantGroup section */ 186 | 187 | /* Begin XCBuildConfiguration section */ 188 | 50DE11281F039FB200FF4737 /* Debug */ = { 189 | isa = XCBuildConfiguration; 190 | buildSettings = { 191 | ALWAYS_SEARCH_USER_PATHS = NO; 192 | CLANG_ANALYZER_NONNULL = YES; 193 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 194 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 195 | CLANG_CXX_LIBRARY = "libc++"; 196 | CLANG_ENABLE_MODULES = YES; 197 | CLANG_ENABLE_OBJC_ARC = YES; 198 | CLANG_WARN_BOOL_CONVERSION = YES; 199 | CLANG_WARN_CONSTANT_CONVERSION = YES; 200 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 201 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 202 | CLANG_WARN_EMPTY_BODY = YES; 203 | CLANG_WARN_ENUM_CONVERSION = YES; 204 | CLANG_WARN_INFINITE_RECURSION = YES; 205 | CLANG_WARN_INT_CONVERSION = YES; 206 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 207 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 208 | CLANG_WARN_UNREACHABLE_CODE = YES; 209 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 210 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 211 | COPY_PHASE_STRIP = NO; 212 | DEBUG_INFORMATION_FORMAT = dwarf; 213 | ENABLE_STRICT_OBJC_MSGSEND = YES; 214 | ENABLE_TESTABILITY = YES; 215 | GCC_C_LANGUAGE_STANDARD = gnu99; 216 | GCC_DYNAMIC_NO_PIC = NO; 217 | GCC_NO_COMMON_BLOCKS = YES; 218 | GCC_OPTIMIZATION_LEVEL = 0; 219 | GCC_PREPROCESSOR_DEFINITIONS = ( 220 | "DEBUG=1", 221 | "$(inherited)", 222 | ); 223 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 224 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 225 | GCC_WARN_UNDECLARED_SELECTOR = YES; 226 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 227 | GCC_WARN_UNUSED_FUNCTION = YES; 228 | GCC_WARN_UNUSED_VARIABLE = YES; 229 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 230 | MTL_ENABLE_DEBUG_INFO = YES; 231 | ONLY_ACTIVE_ARCH = YES; 232 | SDKROOT = iphoneos; 233 | }; 234 | name = Debug; 235 | }; 236 | 50DE11291F039FB200FF4737 /* Release */ = { 237 | isa = XCBuildConfiguration; 238 | buildSettings = { 239 | ALWAYS_SEARCH_USER_PATHS = NO; 240 | CLANG_ANALYZER_NONNULL = YES; 241 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 242 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 243 | CLANG_CXX_LIBRARY = "libc++"; 244 | CLANG_ENABLE_MODULES = YES; 245 | CLANG_ENABLE_OBJC_ARC = YES; 246 | CLANG_WARN_BOOL_CONVERSION = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 250 | CLANG_WARN_EMPTY_BODY = YES; 251 | CLANG_WARN_ENUM_CONVERSION = YES; 252 | CLANG_WARN_INFINITE_RECURSION = YES; 253 | CLANG_WARN_INT_CONVERSION = YES; 254 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 255 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 256 | CLANG_WARN_UNREACHABLE_CODE = YES; 257 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 258 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 259 | COPY_PHASE_STRIP = NO; 260 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 261 | ENABLE_NS_ASSERTIONS = NO; 262 | ENABLE_STRICT_OBJC_MSGSEND = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu99; 264 | GCC_NO_COMMON_BLOCKS = YES; 265 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 266 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 267 | GCC_WARN_UNDECLARED_SELECTOR = YES; 268 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 269 | GCC_WARN_UNUSED_FUNCTION = YES; 270 | GCC_WARN_UNUSED_VARIABLE = YES; 271 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 272 | MTL_ENABLE_DEBUG_INFO = NO; 273 | SDKROOT = iphoneos; 274 | VALIDATE_PRODUCT = YES; 275 | }; 276 | name = Release; 277 | }; 278 | 50DE112B1F039FB200FF4737 /* Debug */ = { 279 | isa = XCBuildConfiguration; 280 | buildSettings = { 281 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 282 | DEVELOPMENT_TEAM = ZP35X6KSCJ; 283 | INFOPLIST_FILE = SignDemo/Info.plist; 284 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 285 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 286 | PRODUCT_BUNDLE_IDENTIFIER = com.yunlong.Nancy; 287 | PRODUCT_NAME = "$(TARGET_NAME)"; 288 | PROVISIONING_PROFILE = "bb333476-67a5-4052-bc45-a26afdd5499c"; 289 | PROVISIONING_PROFILE_SPECIFIER = comyunlongNancy; 290 | }; 291 | name = Debug; 292 | }; 293 | 50DE112C1F039FB200FF4737 /* Release */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 297 | DEVELOPMENT_TEAM = ""; 298 | INFOPLIST_FILE = SignDemo/Info.plist; 299 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 300 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 301 | PRODUCT_BUNDLE_IDENTIFIER = com.yunlong.Nancy; 302 | PRODUCT_NAME = "$(TARGET_NAME)"; 303 | PROVISIONING_PROFILE_SPECIFIER = ""; 304 | }; 305 | name = Release; 306 | }; 307 | /* End XCBuildConfiguration section */ 308 | 309 | /* Begin XCConfigurationList section */ 310 | 50DE110E1F039FB200FF4737 /* Build configuration list for PBXProject "SignDemo" */ = { 311 | isa = XCConfigurationList; 312 | buildConfigurations = ( 313 | 50DE11281F039FB200FF4737 /* Debug */, 314 | 50DE11291F039FB200FF4737 /* Release */, 315 | ); 316 | defaultConfigurationIsVisible = 0; 317 | defaultConfigurationName = Release; 318 | }; 319 | 50DE112A1F039FB200FF4737 /* Build configuration list for PBXNativeTarget "SignDemo" */ = { 320 | isa = XCConfigurationList; 321 | buildConfigurations = ( 322 | 50DE112B1F039FB200FF4737 /* Debug */, 323 | 50DE112C1F039FB200FF4737 /* Release */, 324 | ); 325 | defaultConfigurationIsVisible = 0; 326 | }; 327 | /* End XCConfigurationList section */ 328 | }; 329 | rootObject = 50DE110B1F039FB200FF4737 /* Project object */; 330 | } 331 | -------------------------------------------------------------------------------- /SignDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SignDemo.xcodeproj/project.xcworkspace/xcuserdata/yunlong.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechAlleyBoy/SignDemo/4e2094dff8fac337fa677a3007eb8d44212debd4/SignDemo.xcodeproj/project.xcworkspace/xcuserdata/yunlong.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SignDemo.xcodeproj/xcuserdata/yunlong.xcuserdatad/xcschemes/SignDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /SignDemo.xcodeproj/xcuserdata/yunlong.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SignDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 50DE11121F039FB200FF4737 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /SignDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SignDemo 4 | // 5 | // Created by yunlong on 2017/6/28. 6 | // Copyright © 2017年 yunlong. 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 | -------------------------------------------------------------------------------- /SignDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SignDemo 4 | // 5 | // Created by yunlong on 2017/6/28. 6 | // Copyright © 2017年 yunlong. 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 | -------------------------------------------------------------------------------- /SignDemo/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 | } -------------------------------------------------------------------------------- /SignDemo/BJTSignView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BJTSignView.h 3 | // BJTResearch 4 | // 5 | // Created by yunlong on 2017/6/28. 6 | // Copyright © 2017年 yunlong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BJTSignView : UIView 12 | /** 13 | * 获取签名图片 14 | */ 15 | - (UIImage *)getSignatureImage; 16 | /** 17 | * 清除签名 18 | */ 19 | - (void)clearSignature; 20 | @end 21 | -------------------------------------------------------------------------------- /SignDemo/BJTSignView.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // BJTSignView.m 4 | // BJTResearch 5 | // 6 | // Created by yunlong on 2017/6/28. 7 | // Copyright © 2017年 yunlong. All rights reserved. 8 | // 9 | 10 | #import "BJTSignView.h" 11 | @interface BJTSignView (){ 12 | CGPoint points[5]; 13 | } 14 | @property(nonatomic,assign) NSInteger control; 15 | @property(nonatomic,strong) UIBezierPath *beizerPath; 16 | @end 17 | 18 | @implementation BJTSignView 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame 21 | { 22 | self = [super initWithFrame:frame]; 23 | if (self) { 24 | self.backgroundColor = [UIColor clearColor]; 25 | [self setMultipleTouchEnabled:NO]; 26 | self.beizerPath = [UIBezierPath bezierPath]; 27 | [self.beizerPath setLineWidth:2]; 28 | } 29 | return self; 30 | } 31 | 32 | #pragma mark - 绘图操作 33 | - (void)drawRect:(CGRect)rect{ 34 | //设置签名的颜色 35 | UIColor *strokeColor = [UIColor redColor]; 36 | [strokeColor setStroke]; 37 | 38 | //签名的路径绘制 39 | [self.beizerPath stroke]; 40 | } 41 | 42 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ 43 | self.control = 0; 44 | UITouch *touch = [touches anyObject]; 45 | points[0] = [touch locationInView:self]; 46 | CGPoint startPoint = points[0]; 47 | CGPoint endPoint = CGPointMake(startPoint.x + 1.5, startPoint.y + 2); 48 | [self.beizerPath moveToPoint:startPoint]; 49 | [self.beizerPath addLineToPoint:endPoint]; 50 | } 51 | 52 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ 53 | UITouch *touch = [touches anyObject]; 54 | CGPoint touchPoint = [touch locationInView:self]; 55 | _control++; 56 | points[_control] = touchPoint; 57 | 58 | if (_control == 4){ 59 | points[3] = CGPointMake((points[2].x + points[4].x)/2.0, (points[2].y + points[4].y)/2.0); 60 | 61 | //设置画笔起始点 62 | [self.beizerPath moveToPoint:points[0]]; 63 | 64 | //endPoint终点 controlPoint1、controlPoint2控制点 65 | [self.beizerPath addCurveToPoint:points[3] controlPoint1:points[1] controlPoint2:points[2]]; 66 | 67 | //setNeedsDisplay会自动调用drawRect方法,这样可以拿到UIGraphicsGetCurrentContext,就可以画画了 68 | [self setNeedsDisplay]; 69 | 70 | points[0] = points[3]; 71 | points[1] = points[4]; 72 | _control = 1; 73 | } 74 | } 75 | 76 | #pragma mark - 清除签名 77 | - (void)clearSignature{ 78 | [self.beizerPath removeAllPoints]; 79 | [self setNeedsDisplay]; 80 | } 81 | 82 | #pragma mark - 获取图片 83 | - (UIImage *)getSignatureImage { 84 | //设置为NO,UIView是透明这里的图片就是透明的 85 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, [UIScreen mainScreen].scale); 86 | [self.layer renderInContext:UIGraphicsGetCurrentContext()]; 87 | 88 | UIImage *signatureImage = UIGraphicsGetImageFromCurrentImageContext(); 89 | UIGraphicsEndImageContext(); 90 | NSString* docDir = [NSString stringWithFormat:@"%@/Documents/Image", NSHomeDirectory()]; 91 | [[NSFileManager defaultManager] createDirectoryAtPath:docDir withIntermediateDirectories:YES attributes:nil error:nil]; 92 | NSString *path = [NSString stringWithFormat:@"%@/Documents/Image/IMAGE.PNG", NSHomeDirectory()]; 93 | 94 | //用png是透明的 95 | [UIImagePNGRepresentation(signatureImage) writeToFile: path atomically:YES]; 96 | return signatureImage; 97 | } 98 | 99 | @end 100 | -------------------------------------------------------------------------------- /SignDemo/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 | -------------------------------------------------------------------------------- /SignDemo/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 | -------------------------------------------------------------------------------- /SignDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /SignDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SignDemo 4 | // 5 | // Created by yunlong on 2017/6/28. 6 | // Copyright © 2017年 yunlong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SignDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SignDemo 4 | // 5 | // Created by yunlong on 2017/6/28. 6 | // Copyright © 2017年 yunlong. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "BJTSignView.h" 11 | 12 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height 13 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width 14 | @interface ViewController () 15 | @property(nonatomic,strong) BJTSignView *signView; 16 | @property(nonatomic,strong) UIImageView *imageView; 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view. 24 | self.view.backgroundColor = [UIColor whiteColor]; 25 | //画布 26 | UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 50, kScreenWidth, 200)]; 27 | backView.layer.borderWidth = 2; 28 | backView.layer.borderColor = [[UIColor redColor] CGColor]; 29 | [self.view addSubview:backView]; 30 | self.signView = [[BJTSignView alloc] initWithFrame:backView.bounds]; 31 | [backView addSubview:self.signView]; 32 | 33 | 34 | UIButton *clearBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 260, kScreenWidth, 30)]; 35 | [clearBtn setTitle:@"清除签名" forState:UIControlStateNormal]; 36 | [clearBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; 37 | [self.view addSubview:clearBtn]; 38 | [clearBtn addTarget:self action:@selector(clearBtnClick) forControlEvents:UIControlEventTouchUpInside]; 39 | 40 | UIButton *imageBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 300, kScreenWidth, 30)]; 41 | [imageBtn setTitle:@"生成图片" forState:UIControlStateNormal]; 42 | [imageBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; 43 | [self.view addSubview:imageBtn]; 44 | [imageBtn addTarget:self action:@selector(imageBtnClick) forControlEvents:UIControlEventTouchUpInside]; 45 | 46 | self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake((kScreenWidth - kScreenWidth/2)/2,380 , kScreenWidth/2, 200/2)]; 47 | self.imageView.backgroundColor = [UIColor blackColor]; 48 | [self.view addSubview:self.imageView]; 49 | 50 | } 51 | #pragma mark - 清楚图片 52 | - (void)clearBtnClick{ 53 | [self.signView clearSignature]; 54 | } 55 | 56 | #pragma mark - 生成图片 57 | - (void)imageBtnClick{ 58 | UIImage *image = [self.signView getSignatureImage]; 59 | self.imageView.image = image; 60 | } 61 | 62 | 63 | - (void)didReceiveMemoryWarning { 64 | [super didReceiveMemoryWarning]; 65 | // Dispose of any resources that can be recreated. 66 | } 67 | @end 68 | 69 | -------------------------------------------------------------------------------- /SignDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SignDemo 4 | // 5 | // Created by yunlong on 2017/6/28. 6 | // Copyright © 2017年 yunlong. 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 | --------------------------------------------------------------------------------