Created
May 16, 2020 16:35
-
-
Save markiv/bc43d7c295a883d4e0f1e2138f04a309 to your computer and use it in GitHub Desktop.
Revisions
-
markiv revised this gist
May 16, 2020 . No changes.There are no files selected for viewing
-
markiv created this gist
May 16, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ 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) } }