Proyectos
Ver en GitHub
kenmueller/TextView
Acerca de
The missing TextView in SwiftUI
Otros proyectosCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
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...
Explorar proyectos relacionados
Cargando…