Input content type - SwiftUI
In SwiftUI, you can set a content type by using the textContentType
view modifier.
The following values are defined in UITextContentType
:
addressCity
: entering a cityaddressCityAndState
: entering a city name with a state nameaddressState
: entering a state namebirthdate
: entering a date of birthbirthdateDay
: entering the day component of a birthdatebirthdateMonth
: entering the month component of a birthdatebirthdateYear
: entering the year component of a birthdatecellularEID
: entering an embedded identity document number for an eSIMcellularIMEI
: entering an international mobile equipment identity number for an eSIMcountryName
: entering a country or region namecreditCardExpiration
: entering an expiration date on a credit cardcreditCardExpirationMonth
: entering the month component of an expiration date on a credit cardcreditCardExpirationYear
: entering the year component of an expiration date on a credit cardcreditCardFamilyName
: entering a family name, or last name, on a credit cardcreditCardGivenName
: entering a first name on a credit cardcreditCardMiddleName
: entering a middle name on a credit cardcreditCardName
: entering a name on a credit cardcreditCardNumber
: entering a credit card numbercreditCardSecurityCode
: entering a credit card security codecreditCardType
: entering a credit card typedateTime
: entering a date, time, or durationemailAddress
: entering an email addressfamilyName
: entering a family name, or last nameflightNumber
: entering an airline flight numberfullStreetAddress
: entering a street address that fully identifies a locationgivenName
: entering a first namejobTitle
: entering a job titlelocation
: entering a location, such as a point of interest, an address, or another identifier for a locationmiddleName
: entering a middle namename
: entering a namenamePrefix
: entering a prefix or title, such as Dr.nameSuffix
: entering a suffix, such as Jr.newPassword
: entering a new passwordnickname
: entering a nicknameoneTimeCode
: entering a one-time codeorganizationName
: entering an organization namepassword
: entering a passwordpostalCode
: entering a postal codeshipmentTrackingNumber
: entering a parcel tracking numberstreetAddressLine1
: entering the first line of a street addressstreetAddressLine2
: entering the second line of a street addresssublocality
: entering a sublocalitytelephoneNumber
: entering a telephone numberURL
: entering a URLusername
: entering an account or login name
Example of using textContentType
:
@State var emailAddress: String = ""
var body: some View {
TextField("Email", text: $emailAddress)
.textContentType(.emailAddress)
}