Skip to content

Commit

Permalink
004535 eSoftra iOS uwagi po prezentacji
Browse files Browse the repository at this point in the history
  • Loading branch information
dagi12 committed Jan 16, 2019
1 parent 092c088 commit 6499c53
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Pod/Classes/EPSignatureView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,17 @@ open class EPSignatureView: UIView {
/** scales and repositions the path
*/
open func reposition() {
var ratio = min(self.bounds.width / bezierPath.bounds.width, 1)
ratio = min((self.bounds.height - 64) / bezierPath.bounds.height, ratio)
bezierPath.apply(CGAffineTransform(scaleX: ratio, y: ratio))
setNeedsDisplay()
if !bezierPath.isEmpty {
var ratio = min(self.bounds.width / bezierPath.bounds.width, 1)
ratio = min((self.bounds.height - 64) / bezierPath.bounds.height, ratio)
bezierPath.apply(CGAffineTransform(scaleX: ratio, y: ratio))
let midX = (self.bounds.width - bezierPath.bounds.width) / 2
let midY = (self.bounds.height - bezierPath.bounds.height) / 2
let translateX = -bezierPath.bounds.origin.x + midX
let translateY = -bezierPath.bounds.origin.y + midY
bezierPath.apply(CGAffineTransform(translationX: translateX, y: translateY))
setNeedsDisplay()
}
}

/** Returns the drawn path as Image. Adding subview to this view will also get returned in this image.
Expand All @@ -137,7 +144,7 @@ open class EPSignatureView: UIView {

/** Returns the rect of signature image drawn in the canvas. This can very very useful in croping out the unwanted empty areas in the signature image returned.
*/

open func getSignatureBoundsInCanvas() -> CGRect {
return bezierPath.bounds
}
Expand All @@ -149,7 +156,7 @@ open class EPSignatureView: UIView {
NSKeyedArchiver.archiveRootObject(bezierPath, toFile: localPath)
}
}

open func loadSignature(_ filePath: String) {
if let path = getPath(filePath) {
isSigned = true
Expand Down

0 comments on commit 6499c53

Please sign in to comment.