iPhoneNumberTextField
Quickly implement a text field designed for phone numbers. π±π’

1.
Install iPhoneNumberTextField
.
2.
Add iPhoneNumberTextField
to your project.
import SwiftUI
import iPhoneNumberTextField
struct ContentView: View {
@State var text: String = ""
@State var isEditing: Bool = false
var body: some View {
iPhoneNumberTextField("Placeholder",
text: $text,
isEditing: $isEditing)
}
}
3.
Customize your iPhoneNumberTextField
.
Examples
Starter
Toggle the keyboard with isEditing
.

import SwiftUI
import iPhoneNumberTextField
import iGraphics
struct ContentView: View {
@State var text: String = ""
@State var isEditing: Bool = false
var body: some View {
iPhoneNumberTextField("Placeholder",
text: $text,
isEditing: $isEditing)
.style()
Button(action: { isEditing.toggle() },
label: { iGraphicsBox(.paragraph) })
}
}
Customize
iPhoneNumberTextField
has three required parameters: 1οΈβ£ a placeholder, 2οΈβ£ a text
binding, and 3οΈβ£ an isEditing
binding. iPhoneNumberTextField
also supports a variety of modifiers.
Example: Change the foreground color, accent color, and text alignment with the following code block:
iPhoneNumberTextField("Placeholder", text: $text, isEditing: $isEditing)
.foregroundColor(Color.Purple)
.accentColor(Color.Green)
.multilineTextAlignment(.leading)
Use our exhaustive input list to customize your text field.
Modifier | Description |
---|---|
|
Modifies the text fieldβs font from a UIFont object. π π‘
|
|
Modifies the text color π¨ of the phone number text field. |
|
Modifies the cursor color π of the phone number text field π±π¬ |
|
Modifies the text alignment of a phone number text field. β¬ οΈβοΈβ‘οΈ |
|
Modifies the clear-on-begin-editing setting of a phone number text field. ββΆοΈ |
|
Modifies whether the phone number text field is disabled. β |
|
Modifies the function called when text editing begins. βΆοΈ |
|
Modifies the function called when the user makes any changes to the text in the text field. π¬ |
|
Modifies the function called when text editing ends. π |
|
A default style meant to quickly render an aesthetic phone number input. Style takes 7 parameters βΒ all with defaults β and returns some View . For this reason ensure that .style is your final modifier.
|
|
How tall the text field should be β¬οΈβ¬οΈ, in points. Defaults to 58. |
|
The background color of the text field. π₯π©π¦ |
|
The cursor color of the text field. π΄π’π΅ |
|
The text field's inputted text font. π |
|
The leading padding of the text field. β |
|
The corner radius of the text field's background. γ°οΈβ° |
|
Whether or not the text field should have a shadow. βοΈπ¦ |
Community
Meet the developers behind iPhoneNumberTextField
.

@benjaminsage