Created
May 16, 2020 16:35
-
-
Save markiv/bc43d7c295a883d4e0f1e2138f04a309 to your computer and use it in GitHub Desktop.
FloatingTextField2.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct FloatingTextField: View { | |
let title: String | |
let text: Binding<String> | |
var body: some View { | |
VStack(alignment: .leading, spacing: 2) { | |
Text(title) | |
.font(.caption) | |
.foregroundColor(Color(.placeholderText)) | |
.opacity(text.wrappedValue.isEmpty ? 0 : 1) | |
.offset(y: text.wrappedValue.isEmpty ? 20 : 0) | |
TextField(title, text: text) | |
}.animation(.default) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment