SSSignaturePad 1.0.0

SSSignaturePad 1.0.0

Simform Solutions 维护。



  • Simform Solutions

SSSignaturePad

Version License Platform

SSSignaturePad 是一个轻量级且易于使用的签名板,适用于 iOS 应用程序。它允许用户用手指或笔绘制平滑的签名,并提供了在 SwiftUI 中定制签名板外观和行为的选项。

功能

  • 平滑签名绘制
  • 导出签名图像
  • 清除签名功能

要求

  • iOS 15.0+
  • Xcode 14.0+
  • Swift 5.0+

安装

CocoaPods

SSSignaturePad可通过CocoaPods 使用。要安装它,只需将以下行添加到您的 Podfile

pod 'SSSignaturePad'

SwiftUI 使用示例

    import SwiftUI
    import SSSignaturePad

    struct ContentView: View {
        @State var isSigning: Bool = false
        @State var clearSignature: Bool = false
        @Binding var signatureImage: UIImage?
        @Binding var signaturePDF: Data?

        var body: some View {
            VStack(spacing: 16) {
                ZStack(alignment: isSigning ? .bottomTrailing: .center) {
                    SignatureViewContainer(clearSignature: $clearSignature, signatureImage: $signatureImage, pdfSignature: $signaturePDF)
                        .disabled(!isSigning)
                        .frame(height: 197)
                        .frame(maxWidth: .infinity)
                        .background(.white)
                        .overlay(
                            RoundedRectangle(cornerRadius: 8)
                                .stroke(Color.red, lineWidth: 3)
                        )
                    if isSigning {
                        Button(action: {
                            clearSignature = true
                        }, label: {
                            HStack {
                                Text("Clear")
                                    .font(.callout)
                                    .foregroundColor(.black)
                            }
                            .padding(.horizontal, 12)
                            .frame(height: 28)
                            .background(
                                Capsule()
                                    .fill(.red)
                            )
                        })
                        .offset(.init(width: -12, height: -12))
                    } else {
                        Button(action: {
                            isSigning = true
                        }, label: {
                            VStack(alignment: .center, spacing: 0) {
                                Image(systemName: "pencil")
                                    .resizable()
                                    .foregroundColor(.black)
                                    .frame(width: 20, height: 20)
                                    .padding(8)
                                Text("Sign here")
                                    .font(.footnote)
                                    .foregroundColor(.gray)
                            }
                        })
                    }
                }
                .padding(.top, 16)
                .padding(.horizontal, 3)

            }
            .padding()
        }
    }

如何贡献 🤝

无论您是帮助我们修复错误、改进文档还是提出功能请求,我们都非常愿意接纳您!💪 请查看我们的贡献指南获取有关贡献的想法。

觉得这个示例有用? ❤️

通过加入 star 弹射器 ⭐ 来支持这个存储库。

错误和反馈

对于错误、功能请求和讨论,请使用 GitHub 问题和讨论

查看我们的其他库

MIT 许可证

该项目基于 MIT 许可证 - 请参阅 LICENSE 文件以获取详细信息。