Skip to content

HumorousGhost/TextView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TextView

This project is only for SwiftUI

Due to the incomplete functions of TextEditor in SwiftUI, such as keyboardType setting, etc.,

UITextView is encapsulated for developers to use

Features will continue to be updated

Preview

image

Supported Platforms

  • iOS 13.0
  • macOS 10.15
  • tvOS 13.0
  • watchOS 6.0

Usage

import SwiftUI
import TextView

struct ContentView: View {
    @State var text: String = ""
    var body: some View {
        TextView($text, isTextCenter: true)
            .font(UIFont.systemFont(ofSize: 12))
            .foregroundColor(UIColor.yellow)
            .returnKeyType(.done)
            .returnKeyAutomatically(true)
            .keyboardType(.asciiCapable)
            .isFirstResponder(true)
            .onDidBegin({
                print("did begin editing")
            })
            .onDidEnd({
                print("did end editing")
            })
            .onShouldBegin({
                print("should begin editing")
                return true
            })
            .onShouldEnd({
                print("should end editing")
                return true
            })
            .onSubmit({ returnKeyType in
                print("click keyboard input button")
                return true
            })
            .background(Color.blue)
            .frame(width: 200, height: 100, alignment: .center)
    }
}

Installation

You can add TextView to an Xcode project by adding it as a package dependency.