项目作者: phuhuynh2411

项目描述 :
A TextView for SwiftUI
高级语言: Swift
项目地址: git://github.com/phuhuynh2411/TextView.git
创建时间: 2020-04-27T03:36:59Z
项目社区:https://github.com/phuhuynh2411/TextView

开源协议:

下载


TextView

A TextView for SwiftUI

Basic Usage

  1. struct ContentView: View {
  2. @State var text: String = "This is a testing text."
  3. var body: some View {
  4. TextView(text: $text)
  5. }
  6. }

Change Font Size

  1. TextView(text: $text, font: UIFont.systemFont(ofSize: 17))

Add Placeholder text

  1. ZStack(alignment: .topLeading) {
  2. TextView(text: $text, font: UIFont.systemFont(ofSize: 17))
  3. .frame(height: 100)
  4. if text.isEmpty {
  5. Text("Type something...")
  6. .foregroundColor(.secondary)
  7. .offset(x: 5, y: 5)
  8. }
  9. }

More simpler way to add the placeholder for the text view

```swift
PlaceholderTextView(“Description”, text: self.$text)