TextField works well with the font modifier. Use the font modifier to change TextField’s font family, size, weight etc. Applied font changes also affect placeholder text in TextField.
For our example, we will use two pre-installed custom fonts in iOS called Chalkduster and Georgia.
struct TextFieldExample: View {
@State private var title: String = ""
@State private var category: String = ""
@State private var type: String = ""
var body: some View {
VStack {
Text("DevTechie Courses")
.font(.largeTitle)
VStack(alignment: .leading) {
Text("Enter new course title")
.font(.title3)
TextField("Course title", text: $title)
.textFieldStyle(.roundedBorder)
.font(.custom("Chalkduster", size: 16))
TextField("Course category", text: $category)
.textFieldStyle(.roundedBorder)
.font(.custom("Georgia", size: 16))
TextField("Course type", text: $type)
.textFieldStyle(.roundedBorder)
.font(.system(size: 14, weight: .heavy, design: .rounded))
}.padding(.top, 20)
}.padding()
}
}