How i will copy text in swiftui?

    @State var copiedText: String = ""
    private let pastboard = UIPasteboard.general
    
    var body: some View {
        
        
        TextField("This is plceholdr", text: $myText)
            .border(.red).padding()
        
        
        Button {
            pastboard.string = copiedText
        } label: {
            Label("Copy to Clipboard", systemImage: "doc.on.doc")
        }
    }

926 thoughts on “How i will copy text in swiftui?

Leave a Reply