Projekte
Auf GitHub ansehen
kenmueller/TextView
Über uns
The missing TextView in SwiftUI
Weitere ProjekteGemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
OriginalTextView
The missing TextView in SwiftUI
Download
- File -> Swift Packages -> Add Package Dependency...
- Select your project
- Enter
https://github.com/kenmueller/TextViewfor the package repository URL - Select Branch: master
- Click Finish
Inputs
text: Binding<String>isEditing: Binding<Bool>- The
TextViewwill modify the value when it is selected and deselected - You can also modify this value to automatically select and deselect the
TextView
- The
placeholder: String? = niltextAlignment: TextView.TextAlignment = .lefttextHorizontalPadding: CGFloat = 0textVerticalPadding: CGFloat = 7placeholderAlignment: Alignment = .topLeadingplaceholderHorizontalPadding: CGFloat = 4.5placeholderVerticalPadding: CGFloat = 7font: UIFont = .preferredFont(forTextStyle: .body)- By default, the font is a body-style font
textColor: UIColor = .blackplaceholderColor: Color = .graybackgroundColor: UIColor = .whitecontentType: TextView.ContentType? = nil- For semantic purposes only
autocorrection: TextView.Autocorrection = .defaultautocapitalization: TextView.Autocapitalization = .sentencesisSecure: Bool = falseisEditable: Bool = trueisSelectable: Bool = trueisScrollingEnabled: Bool = trueisUserInteractionEnabled: Bool = trueshouldWaitUntilCommit: Bool = true- For multi-stage input methods, setting this to
falsewould make theTextViewcompletely unusable. - This option will ignore text changes when the user is still composing characters.
- For multi-stage input methods, setting this to
shouldChange: TextView.ShouldChangeHandler? = nil- Of type
(NSRange, String) -> Booland is called with the arguments totextView(_:shouldChangeTextIn:replacementText:).
- Of type
Example
import SwiftUI
import TextView
struct ContentView: View {
@State var text = ""
@State var isEditing = false
var body: some View {
VStack {
Button(action: {
self.isEditing.toggle()
}) {
Text("\(isEditing ? "Stop" : "Start") editing")
}
TextView(
text: $text,
isEditing: $isEditing,
placeholder: "Enter text here"
)
}
}
}
You might also find these useful...
Ähnliche Projekte entdecken
Wird geladen…