Skip to content

Instantly share code, notes, and snippets.

@blsage
Created November 3, 2020 21:12
Show Gist options
  • Save blsage/3273a9682ea4a99988744b652082252b to your computer and use it in GitHub Desktop.
Save blsage/3273a9682ea4a99988744b652082252b to your computer and use it in GitHub Desktop.
Custom style for phone number field
import SwiftUI
import iPhoneNumberField
struct ContentView: View {
@State var text: String = ""
@State var isEditing: Bool = false
var body: some View {
iPhoneNumberField("(000) 000-0000", text: $text, isEditing: $isEditing)
.flagHidden(false)
.flagSelectable(true)
.font(UIFont(size: 30, weight: .light, design: .monospaced))
.maximumDigits(10)
.foregroundColor(Color.pink)
.clearButtonMode(.whileEditing)
.onClear { _ in isEditing.toggle() }
.accentColor(Color.orange)
.padding()
.background(Color.white)
.cornerRadius(10)
.shadow(color: isEditing ? .lightGray : .white, radius: 10)
.padding()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment