Skip to content

Commit

Permalink
Merge pull request #34 from GJNilsen/Development
Browse files Browse the repository at this point in the history
v1.1 Added Vector Graphics Support
  • Loading branch information
GJ Nilsen authored May 3, 2017
2 parents e688e0c + a415fae commit 6c40cc5
Show file tree
Hide file tree
Showing 13 changed files with 372 additions and 133 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Yuppielabel
Copyright (c) 2014 - 2017 The YPDrawSignatureView Project Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
102 changes: 68 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Simple class for capturing signatures.


## Swift 3

The class supports Swift 3.
Expand All @@ -10,27 +11,37 @@ This branch is not backwards compatible, please download the previous release if
- Swift 3.0 will be supported
- Swift 2.3 will not be supported


## Usage

Add a new `UIView` where you want the signature capture field. Set its class to `YPDrawSignatureView`, and connect it to an `@IBOutlet` property in your `UIViewController`. For saving and clearing the signature, add two buttons to your view controller. Hook each button up to an `@IBAction` function.

![ScreenShot](ibss.png?raw=true "Interface Builder Attributes Inspector panel")

With the view selected, choose the IB Attributes Inspector panel to set custom values, or set them in code where you initialize the signature view.
With the view selected, choose the IB Attributes Inspector panel to set custom values, or set them in code where you initialise the signature view.


## New Feature

On ground of popular demand, added signature export as Vector Path in PDF Data Format.


#### Methods

* `clear()`

This clears the view
Clears signature

* `getSignature()`

This returns the signature with the bounds of the view
Returns signature with bounds of YPDrawSignatureView instance

* `getCroppedSignature()`

This returns the signature with the bounds of the signature
Returns signature with bounds of signature

* ̀getPDFSignature()`
Returns signature as Vector Path PDF Data Format

#### Properties

Expand All @@ -46,17 +57,14 @@ Sets the width of the signature stroke

Sets the UIColor of the signature stroke

* `signatureBackgroundColor: UIColor`

Sets the background UIColor of the view

#### Optional Protocol Methods

* `startedDrawing()`
* `didStart()`

Notifies the delegate when someone starts a stroke in the view

* `finishedDrawing()`
* `didFinish()`

Notifies the delegate when someone finishes a stroke in the view

Expand All @@ -65,38 +73,56 @@ Notifies the delegate when someone finishes a stroke in the view
The following sample code checks if there is a signature in the view before getting it.

```
class MyViewController: UIViewController, YPSignatureDelegate {
@IBOutlet weak var drawSignatureView: YPDrawSignatureView!
class ViewController: UIViewController, YPSignatureDelegate {
// Connect this Outlet to the Signature View
@IBOutlet weak var signatureView: YPDrawSignatureView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Setting this view controller as the signature view delegate, so the didStart() and
// didFinish() methods below in the delegate section are called.
signatureView.delegate = self
}
drawSignatureView.delegate = self
// Function for clearing the content of signature view
@IBAction func clearSignature(_ sender: UIButton) {
// This is how the signature gets cleared
self.signatureView.clear()
}
@IBAction func save(sender: AnyObject) {
// Checking if the view actually contains a signature
if drawSignatureView.doesContainSignature {
let img = drawSignatureView.getCroppedSignature()
// Do something with img
} else {
// Alert the user or do something else
// Function for saving signature
@IBAction func saveSignature(_ sender: UIButton) {
// Getting the Signature Image from self.drawSignatureView using the method getSignature().
if let signatureImage = self.signatureView.getSignature(scale: 10) {
// Saving signatureImage from the line above to the Photo Roll.
// The first time you do this, the app asks for access to your pictures.
UIImageWriteToSavedPhotosAlbum(signatureImage, nil, nil, nil)
// Since the Signature is now saved to the Photo Roll, the View can be cleared anyway.
self.signatureView.clear()
}
}
@IBAction func clear(sender: AnyObject) {
drawSignatureView.clear()
}
// MARK: - Optional delegate methods
func startedDrawing() {
// Do something when start drawing
// MARK: - Delegate Methods
// The delegate functions gives feedback to the instanciating class. All functions are optional,
// meaning you just implement the one you need.
// didStart() is called right after the first touch is registered in the view.
// For example, this can be used if the view is embedded in a scroll view, temporary
// stopping it from scrolling while signing.
func didStart() {
print("Started Drawing")
}
func finishedDrawing() {
// Do something else when finished drawing
// didFinish() is called rigth after the last touch of a gesture is registered in the view.
// Can be used to enabe scrolling in a scroll view if it has previous been disabled.
func didFinish() {
print("Finished Drawing")
}
}
```
Expand Down Expand Up @@ -130,7 +156,15 @@ YPDrawSignatureView is available under the MIT license. See the [LICENSE](LICENS

## Update history

### v1.0.1 - 5/2/17
### v1.1 - 5/3/17

* Added PDF support for exporting signature as high resolution vector graphics
* Deprecated methods and properties are properly marked
* Cleaning up method naming
* Delegate methods are now optional
* Sample project updated to latest settings

#### v1.0.1 - 5/2/17

* Minor bugfix

Expand Down
27 changes: 18 additions & 9 deletions SignatureTest/SignatureTest.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
4BE489EE1C252F8B00741EAD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4BE489EC1C252F8B00741EAD /* Main.storyboard */; };
4BE489F01C252F8B00741EAD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4BE489EF1C252F8B00741EAD /* Assets.xcassets */; };
4BE489F31C252F8B00741EAD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4BE489F11C252F8B00741EAD /* LaunchScreen.storyboard */; };
4BE489FE1C252F8E00741EAD /* SignatureTestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE489FD1C252F8E00741EAD /* SignatureTestTests.swift */; };
4BE48A091C252F8F00741EAD /* SignatureTestUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE48A081C252F8F00741EAD /* SignatureTestUITests.swift */; };
4BE48A171C252FC600741EAD /* YPDrawSignatureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BE48A161C252FC600741EAD /* YPDrawSignatureView.swift */; };
EACD35371EB929F000C20EF8 /* SignatureViewTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = EACD35361EB929F000C20EF8 /* SignatureViewTest.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -43,12 +43,12 @@
4BE489F21C252F8B00741EAD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4BE489F41C252F8C00741EAD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4BE489F91C252F8E00741EAD /* SignatureTestTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SignatureTestTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4BE489FD1C252F8E00741EAD /* SignatureTestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignatureTestTests.swift; sourceTree = "<group>"; };
4BE489FF1C252F8E00741EAD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4BE48A041C252F8F00741EAD /* SignatureTestUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SignatureTestUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4BE48A081C252F8F00741EAD /* SignatureTestUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignatureTestUITests.swift; sourceTree = "<group>"; };
4BE48A0A1C252F8F00741EAD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4BE48A161C252FC600741EAD /* YPDrawSignatureView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YPDrawSignatureView.swift; sourceTree = "<group>"; };
EACD35361EB929F000C20EF8 /* SignatureViewTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignatureViewTest.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -113,8 +113,8 @@
4BE489FC1C252F8E00741EAD /* SignatureTestTests */ = {
isa = PBXGroup;
children = (
4BE489FD1C252F8E00741EAD /* SignatureTestTests.swift */,
4BE489FF1C252F8E00741EAD /* Info.plist */,
EACD35361EB929F000C20EF8 /* SignatureViewTest.swift */,
);
path = SignatureTestTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -191,7 +191,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = Yuppielabel;
TargetAttributes = {
4BE489E41C252F8B00741EAD = {
Expand All @@ -200,6 +200,7 @@
};
4BE489F81C252F8E00741EAD = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = 784F7MSSDM;
LastSwiftMigration = 0800;
TestTargetID = 4BE489E41C252F8B00741EAD;
};
Expand Down Expand Up @@ -272,7 +273,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4BE489FE1C252F8E00741EAD /* SignatureTestTests.swift in Sources */,
EACD35371EB929F000C20EF8 /* SignatureViewTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -332,8 +333,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -355,7 +358,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -377,8 +380,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -394,7 +399,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -406,9 +411,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = SignatureTest/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.yuppielabel.SignatureTest;
PRODUCT_BUNDLE_IDENTIFIER = SignatureTest;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
Expand All @@ -418,9 +424,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = SignatureTest/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.yuppielabel.SignatureTest;
PRODUCT_BUNDLE_IDENTIFIER = SignatureTest;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
Expand All @@ -431,6 +438,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = 784F7MSSDM;
INFOPLIST_FILE = SignatureTestTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.yuppielabel.SignatureTestTests;
Expand All @@ -444,6 +452,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = 784F7MSSDM;
INFOPLIST_FILE = SignatureTestTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.yuppielabel.SignatureTestTests;
Expand Down
8 changes: 4 additions & 4 deletions SignatureTest/SignatureTest/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// YPDrawSignatureView is open source
// Version 1.0
// Version 1.1
//
// Copyright (c) 2014 - 2016 Yuppielabel and the project contributors
// Copyright (c) 2014 - 2017 The YPDrawSignatureView Project Contributors
// Available under the MIT license
//
// See https://github.com/yuppielabel/YPDrawSignatureView/blob/master/LICENSE for license information
// See https://github.com/yuppielabel/YPDrawSignatureView/blob/master/README.md for the list project contributors
// https://github.com/GJNilsen/YPDrawSignatureView/blob/master/LICENSE License Information
// https://github.com/GJNilsen/YPDrawSignatureView/blob/master/README.md Project Contributors

import UIKit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -30,6 +40,16 @@
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
Expand Down Expand Up @@ -59,6 +79,11 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
Expand Down
Loading

0 comments on commit 6c40cc5

Please sign in to comment.