SignatureView
这个仓库用于在 iOS 应用程序(Swift / ObjectiveC)中使用数字签名视图。该视图可以在 Swift / ObjectiveC 应用程序中提供数字签名视图,用户可以绘制签名并在应用程序中使用它(例如:签名任何文档)。此视图有三个按钮
- 重置 - 用于重置签名。
- 调整大小 - 通过拖动调整签名视图的大小。
- 完成 - 获取可用于应用程序的签名图像。
可以通过 CocoaPods / Carthage 进行安装。
1. CocoaPods
pod 'SignatureSDK'
2. Carthage
github "SharadGoyal/SignatureView"
使用此框架的步骤
- 在您的文件中导入“Sign”框架(例如:import Sign)
- 创建 Configuration 类的对象。(例如:let config = Configuration())
- 为了自定义签名视图的外观和感觉,设置 Configuration 类的属性。
- 使用配置对象和闭包来获取签名图像初始化 SignatureView。
@objc public class Configuration : NSObject {
/// label placeholder text
@objc public var placeholderText: String
/// reset button title
@objc public var resetBtnTitle: String
/// resize button title
@objc public var resizeBtnTitle: String
/// done button title
@objc public var doneBtnTitle: String
/// buttons background color
@objc public var btnBackgroundColor: UIColor
/// buttons title color
@objc public var btnTitleColor: UIColor
/// to specify signature color
@objc public var signatureColor: UIColor
/// to specify signature line width
@objc public var signatureWidth: CGFloat
/// label text color
@objc public var labelTextColor: UIColor
/// label and button font name
@objc public var fontName: String
/// to draw rounded button
@objc public var showRounded: Bool
/// to enable Gradiant Color
@objc public var enableGradiant: Bool
/// array of gradient colors
@objc public var gradientColors: [UIColor]
/// gradient color direction
@objc public var gradientDirection: GradientDirection
/// UIButton press effect type
@objc public var buttonPressEffectType: PressEffectType
/// UIButton border color
public var btnBorderColor: UIColor
/// UIButton corner radius
@objc public var btnCornerRadius: CGFloat
/// UIButton border width
@objc public var btnBorderWidth: CGFloat
}
基本代码示例
import UIKit
import Sign
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func clickedBtn(_ sender: UIButton) {
var config = Configuration()
config.placeholderText = "Type Here"
config.btnBackgroundColor = UIColor.blue
config.enableGradiant = true
config.showRounded = true
let _ = SignatureView.init(config: config) { (image) in
print("image received...")
}
}
}