Skip to content

Commit

Permalink
Updated to Swift 3
Browse files Browse the repository at this point in the history
Updated file to reflect changes to the Swift 3 branch
  • Loading branch information
GJ Nilsen authored Jun 14, 2016
1 parent deec6a2 commit 59bccf4
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Simple class for capturing signatures.

Inspired by [Capture a Signature on iOS](https://www.altamiracorp.com/blog/employee-posts/capture-a-signature-on-ios) by Jason Harwig, and [Macheads101](https://www.youtube.com/user/macheads101), he has a great [tutorial](https://www.youtube.com/watch?v=8KV1o9hPF5E&list=UU7fIuG6L5EPc9Ijq2_BCmIg) on YouTube.
## Swift 3

## Swift 2.2

The class supports Swift 2.2
The class supports Swift 3 as shipped with Xcode Version 8.0 beta (8S128d).
The class will be updated for each iteration until the final Swift 3.0 release.
This branch is not backwards compatible.

## Usage

Expand All @@ -18,21 +18,21 @@ With the view selected, choose the IB Attributes Inspector panel to set custom v

#### Methods

* `clearSignature()`
* `clear()`

This clears the view

* `getSignature()`

This returns the signature with the bounds of the view

* `getSignatureCropped()`
* `getCroppedSignature()`

This returns the signature with the bounds of the signature

#### Properties

* `containsSignature: Bool`
* `doesContainSignature: Bool`

This is a computed read-only property returning `true` if the view actually contains a signature

Expand All @@ -50,11 +50,11 @@ Sets the background UIColor of the view

#### Optional Protocol Methods

* `startedSignatureDrawing()`
* `startedDrawing()`

Notifies the delegate when someone starts a stroke in the view

* `finishedSignatureDrawing()`
* `finishedDrawing()`

Notifies the delegate when someone finishes a stroke in the view

Expand All @@ -63,7 +63,7 @@ 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, YPDrawSignatureViewDelegate {
class MyViewController: UIViewController, YPSignatureDelegate {
@IBOutlet weak var drawSignatureView: YPDrawSignatureView!
Expand All @@ -76,24 +76,24 @@ class MyViewController: UIViewController, YPDrawSignatureViewDelegate {
@IBAction func save(sender: AnyObject) {
// Checking if the view actually contains a signature
if drawSignatureView.containsSignature {
let img = drawSignatureView.getSignatureCropped()
if drawSignatureView.doesContainSignature {
let img = drawSignatureView.getCroppedSignature()
// Do something with img
} else {
// Alert the user or do something else
}
}
@IBAction func clear(sender: AnyObject) {
drawSignatureView.clearSignature()
drawSignatureView.clear()
}
// MARK: - Optional delegate methods
func startedSignatureDrawing() {
func startedDrawing() {
// Do something when start drawing
}
func finishedSignatureDrawing() {
func finishedDrawing() {
// Do something else when finished drawing
}
}
Expand Down

0 comments on commit 59bccf4

Please sign in to comment.