Skip to content

Custom form styling

Last updated: October 20, 2022

For complete control over how the various UI elements on your forms look, you can use our fully custom solution.

You can use the properties listed in the structs below to edit each individual UI component displayed across the forms:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
private enum Constants {
static let mainFontColor = UIColor(red: 0 / 255, green: 204 / 255, blue: 45 / 255, alpha: 1)
static let secondaryFontColor = UIColor(red: 177 / 255, green: 177 / 255, blue: 177 / 255, alpha: 1)
static let errorColor = UIColor.red
static let backgroundColor = UIColor(red: 23 / 255, green: 32 / 255, blue: 30 / 255, alpha: 1)
static let textFieldBackgroundColor = UIColor(red: 36 / 255.0, green: 48 / 255.0, blue: 45 / 255.0, alpha: 1.0)
static let borderRadius: CGFloat = 4
static let borderWidth: CGFloat = 1
}
// Main payment form
struct PaymentFormStyleCustom1: PaymentFormStyle {
var backgroundColor: UIColor = Constants.backgroundColor
var headerView: PaymentHeaderCellStyle = StyleOrganiser.PaymentHeaderViewStyle()
var addBillingSummary: CellButtonStyle? = StyleOrganiser.BillingStartButton()
var editBillingSummary: BillingSummaryViewStyle? = StyleOrganiser.BillingSummaryStyle()
var cardholderInput: CellTextFieldStyle?
var cardNumber: CellTextFieldStyle = StyleOrganiser.CardNumberSection()
var expiryDate: CellTextFieldStyle = StyleOrganiser.ExpiryDateSection()
var securityCode: CellTextFieldStyle? = StyleOrganiser.SecurityNumberSection()
var payButton: ElementButtonStyle = StyleOrganiser.PayButtonFormStyleCustom1()
}
struct BillingFormStyleCustom1: BillingFormStyle {
var mainBackground: UIColor = Constants.backgroundColor
var header: BillingFormHeaderCellStyle = StyleOrganiser.BillingHeaderViewStyle()
var cells: [BillingFormCell] = [
.fullName(StyleOrganiser.BillingFullNameInput()),
.addressLine1(StyleOrganiser.BillingAddressLine1Input()),
.addressLine2(StyleOrganiser.BillingAddressLine2Input()),
.city(StyleOrganiser.BillingCityInput()),
.state(StyleOrganiser.BillingStateInput()),
.postcode(StyleOrganiser.BillingPostcodeInput()),
.country(StyleOrganiser.BillingCountryInput()),
.phoneNumber(StyleOrganiser.BillingPhoneInput())
]
}
private enum StyleOrganiser {
struct PaymentHeaderViewStyle: PaymentHeaderCellStyle {
var shouldHideAcceptedCardsList = true
var backgroundColor: UIColor = Constants.backgroundColor
var headerLabel: ElementStyle? = PaymentHeaderLabel()
var subtitleLabel: ElementStyle? = PaymentHeaderSubtitle()
var schemeIcons: [UIImage?] = []
}
struct BillingHeaderViewStyle: BillingFormHeaderCellStyle {
var backgroundColor: UIColor = .clear
var headerLabel: ElementStyle = BillingHeaderLabel()
var cancelButton: ElementButtonStyle = CancelButtonStyle()
var doneButton: ElementButtonStyle = DoneButtonStyle()
}
struct BillingHeaderLabel: ElementStyle {
var textAlignment: NSTextAlignment = .natural
var isHidden = false
var text: String = "Billing address"
var font = UIFont(sfMono: .semibold, size: 24)
var backgroundColor: UIColor = .clear
var textColor: UIColor = Constants.mainFontColor
}
struct PayButtonFormStyleCustom1: ElementButtonStyle {
var image: UIImage?
var textAlignment: NSTextAlignment = .center
var text: String = "Pay 100$"
var font = UIFont.systemFont(ofSize: 15)
var disabledTextColor: UIColor = Constants.secondaryFontColor
var disabledTintColor: UIColor = Constants.mainFontColor.withAlphaComponent(0.2)
var activeTintColor: UIColor = Constants.mainFontColor
var backgroundColor: UIColor = Constants.mainFontColor
var textColor: UIColor = .white
var normalBorderColor: UIColor = .clear
var focusBorderColor: UIColor = .clear
var errorBorderColor: UIColor = .clear
var imageTintColor: UIColor = .clear
var isHidden = false
var isEnabled = true
var height: Double = 56
var width: Double = 0
var cornerRadius: CGFloat = 10
var borderWidth: CGFloat = 0
var textLeading: CGFloat = 0
}
struct CancelButtonStyle: ElementButtonStyle {
var textAlignment: NSTextAlignment = .natural
var isEnabled = true
var disabledTextColor: UIColor = Constants.secondaryFontColor
var disabledTintColor: UIColor = .clear
var activeTintColor: UIColor = .clear
var imageTintColor: UIColor = .clear
var normalBorderColor: UIColor = .clear
var focusBorderColor: UIColor = .clear
var errorBorderColor: UIColor = .clear
var image: UIImage?
var textLeading: CGFloat = 0
var cornerRadius: CGFloat = Constants.borderRadius
var borderWidth: CGFloat = Constants.borderWidth
var height: Double = 60
var width: Double = 70
var isHidden = false
var text: String = "Cancel"
var font = UIFont(sfMono: .semibold, size: 17)
var backgroundColor: UIColor = .clear
var textColor: UIColor = Constants.mainFontColor
}
struct DoneButtonStyle: ElementButtonStyle {
var textAlignment: NSTextAlignment = .natural
var isEnabled = true
var disabledTextColor: UIColor = Constants.secondaryFontColor
var disabledTintColor: UIColor = .clear
var activeTintColor: UIColor = .clear
var imageTintColor: UIColor = .clear
var normalBorderColor: UIColor = .clear
var focusBorderColor: UIColor = .clear
var errorBorderColor: UIColor = .clear
var image: UIImage?
var textLeading: CGFloat = 0
var cornerRadius: CGFloat = Constants.borderRadius
var borderWidth: CGFloat = Constants.borderWidth
var height: Double = 60
var width: Double = 70
var isHidden = false
var text: String = "Done"
var font = UIFont(sfMono: .semibold, size: 17)
var backgroundColor: UIColor = .clear
var textColor: UIColor = Constants.mainFontColor
}
struct PaymentHeaderLabel: ElementStyle {
var textAlignment: NSTextAlignment = .natural
var isHidden = false
var text: String = "Payment details"
var font = UIFont(size: 24)
var backgroundColor: UIColor = .clear
var textColor: UIColor = Constants.mainFontColor
}
struct PaymentHeaderSubtitle: ElementStyle {
var textAlignment: NSTextAlignment = .natural
var isHidden = false
var text: String = "Visa, Mastercard and Maestro accepted."
var font = UIFont(size: 12)
var backgroundColor: UIColor = .clear
var textColor: UIColor = Constants.mainFontColor
}
struct CardNumberSection: CellTextFieldStyle {
var isMandatory = true
var backgroundColor: UIColor = .clear
var textfield: ElementTextFieldStyle = TextFieldStyle()
var title: ElementStyle? = TitleStyle(text: "Card number")
var mandatory: ElementStyle? = MandatoryStyle(text: "")
var hint: ElementStyle?
var error: ElementErrorViewStyle? = ErrorViewStyle(text: "Insert a valid card number")
}
struct ExpiryDateSection: CellTextFieldStyle {
var textfield: ElementTextFieldStyle = TextFieldStyle(placeholder: "_ _ / _ _")
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "Expiry date")
var mandatory: ElementStyle? = MandatoryStyle(text: "")
var hint: ElementStyle?
var error: ElementErrorViewStyle? = ErrorViewStyle(text: "Insert a valid expiry date")
}
struct SecurityNumberSection: CellTextFieldStyle {
var textfield: ElementTextFieldStyle = TextFieldStyle()
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "Security code")
var mandatory: ElementStyle? = MandatoryStyle(text: "")
var hint: ElementStyle?
var error: ElementErrorViewStyle? = ErrorViewStyle(text: "Insert a valid security code")
}
struct TextFieldStyle: ElementTextFieldStyle {
var textAlignment: NSTextAlignment = .natural
var text: String = ""
var isSupportingNumericKeyboard = true
var height: Double = 56
var cornerRadius: CGFloat = Constants.borderRadius
var borderWidth: CGFloat = Constants.borderWidth
var placeholder: String?
var tintColor: UIColor = Constants.mainFontColor
var normalBorderColor: UIColor = .clear
var focusBorderColor: UIColor = .clear
var errorBorderColor: UIColor = Constants.errorColor
var isHidden = false
var font = UIFont(size: 15)
var backgroundColor: UIColor = Constants.textFieldBackgroundColor
var textColor: UIColor = Constants.mainFontColor
}
struct TitleStyle: ElementStyle {
var textAlignment: NSTextAlignment = .natural
var text: String
var isHidden = false
var font = UIFont(size: 15)
var backgroundColor: UIColor = .clear
var textColor: UIColor = Constants.mainFontColor
}
struct MandatoryStyle: ElementStyle {
var textAlignment: NSTextAlignment = .natural
var text: String
var isHidden = false
var font = UIFont(size: 13)
var backgroundColor: UIColor = .clear
var textColor: UIColor = Constants.secondaryFontColor
}
struct SubtitleElementStyle: ElementStyle {
var textAlignment: NSTextAlignment = .natural
var text: String
var textColor: UIColor = Constants.secondaryFontColor
var backgroundColor: UIColor = .clear
var tintColor: UIColor = Constants.mainFontColor
var image: UIImage?
var height: Double = 30
var isHidden = false
var font = UIFont(size: 13)
}
struct ErrorViewStyle: ElementErrorViewStyle {
var textAlignment: NSTextAlignment = .natural
var text: String
var textColor: UIColor = Constants.errorColor
var backgroundColor: UIColor = .clear
var tintColor: UIColor = Constants.errorColor
var image: UIImage?
var height: Double = 30
var isHidden = true
var font = UIFont(size: 13)
}
struct BillingStartButton: CellButtonStyle {
var isMandatory = true
var button: ElementButtonStyle = AddBillingDetailsButtonStyle()
var backgroundColor: UIColor = .red// .clear
var title: ElementStyle? = TitleStyle(text: "Billing address")
var mandatory: ElementStyle?
var hint: ElementStyle? = {
var element = SubtitleElementStyle(text: "We need this information as an additional security measure to verify this card.")
element.textColor = Constants.mainFontColor
return element
}()
var error: ElementErrorViewStyle?
}
struct BillingSummaryStyle: BillingSummaryViewStyle {
var summary: ElementStyle? = BillingSummaryElementStyle(text: "")
var cornerRadius: CGFloat = Constants.borderRadius
var borderWidth: CGFloat = Constants.borderWidth
var separatorLineColor: UIColor = Constants.secondaryFontColor
var borderColor: UIColor = Constants.mainFontColor
var button: ElementButtonStyle = AddBillingDetailsButtonStyle(textLeading: 20, text: "\u{276F} Update Billing Address")
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "Billing address")
var mandatory: ElementStyle?
var hint: ElementStyle? = {
var element = SubtitleElementStyle(text: "We need this information as an additional security measure to verify this card.")
element.textColor = Constants.mainFontColor
return element
}()
var error: ElementErrorViewStyle?
}
struct AddBillingDetailsButtonStyle: ElementButtonStyle {
var textAlignment: NSTextAlignment = .natural
var isEnabled = true
var disabledTextColor: UIColor = Constants.secondaryFontColor
var disabledTintColor: UIColor = Constants.secondaryFontColor
var activeTintColor: UIColor = Constants.mainFontColor
var imageTintColor: UIColor = .clear
var normalBorderColor: UIColor = .clear
var focusBorderColor: UIColor = .clear
var errorBorderColor: UIColor = .clear
var image: UIImage?
var textLeading: CGFloat = 0
var cornerRadius: CGFloat = 0
var borderWidth: CGFloat = 0
var height: Double = 56
var width: Double = 300
var isHidden = false
var text: String = "\u{276F} Add billing address"
var font = UIFont(sfMono: .semibold, size: 15)
var backgroundColor: UIColor = .clear
var textColor: UIColor = Constants.mainFontColor
}
struct BillingFullNameInput: CellTextFieldStyle {
var textfield: ElementTextFieldStyle = TextFieldStyle(isSupportingNumericKeyboard: false)
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "Full name")
var mandatory: ElementStyle?
var hint: ElementStyle?
var error: ElementErrorViewStyle?
}
struct BillingAddressLine1Input: CellTextFieldStyle {
var textfield: ElementTextFieldStyle = TextFieldStyle(isSupportingNumericKeyboard: false)
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "Address line 1")
var mandatory: ElementStyle?
var hint: ElementStyle?
var error: ElementErrorViewStyle?
}
struct BillingAddressLine2Input: CellTextFieldStyle {
var textfield: ElementTextFieldStyle = TextFieldStyle(isSupportingNumericKeyboard: false)
var isMandatory = false
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "Address line 2")
var mandatory: ElementStyle? = MandatoryStyle(text: "Optional")
var hint: ElementStyle?
var error: ElementErrorViewStyle?
}
struct BillingCityInput: CellTextFieldStyle {
var textfield: ElementTextFieldStyle = TextFieldStyle(isSupportingNumericKeyboard: false)
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "City")
var mandatory: ElementStyle?
var hint: ElementStyle?
var error: ElementErrorViewStyle?
}
struct BillingStateInput: CellTextFieldStyle {
var textfield: ElementTextFieldStyle = TextFieldStyle(isSupportingNumericKeyboard: false)
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "State")
var mandatory: ElementStyle?
var hint: ElementStyle?
var error: ElementErrorViewStyle?
}
struct BillingPostcodeInput: CellTextFieldStyle {
var textfield: ElementTextFieldStyle = TextFieldStyle(isSupportingNumericKeyboard: false)
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "Postcode/Zip")
var mandatory: ElementStyle?
var hint: ElementStyle?
var error: ElementErrorViewStyle?
}
struct BillingCountryInput: CellButtonStyle {
var button: ElementButtonStyle = BillingCountryButton()
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "Country")
var mandatory: ElementStyle?
var hint: ElementStyle?
var error: ElementErrorViewStyle?
}
struct BillingPhoneInput: CellTextFieldStyle {
var textfield: ElementTextFieldStyle = TextFieldStyle()
var isMandatory = true
var backgroundColor: UIColor = .clear
var title: ElementStyle? = TitleStyle(text: "Phone number")
var mandatory: ElementStyle?
var hint: ElementStyle? = SubtitleElementStyle(text: "We will only use this to confirm identity if necessary")
var error: ElementErrorViewStyle?
}
struct BillingSummaryElementStyle: ElementStyle {
var textAlignment: NSTextAlignment = .natural
var isHidden = false
var text: String
var font = UIFont(size: 14)
var backgroundColor: UIColor = .clear
var textColor: UIColor = Constants.secondaryFontColor
}
struct BillingCountryButton: ElementButtonStyle {
var textAlignment: NSTextAlignment = .natural
var isEnabled = true
var disabledTextColor: UIColor = Constants.secondaryFontColor
var disabledTintColor: UIColor = .clear
var activeTintColor: UIColor = Constants.mainFontColor
var imageTintColor: UIColor = Constants.mainFontColor
var normalBorderColor: UIColor = .clear
var focusBorderColor: UIColor = .clear
var errorBorderColor: UIColor = .clear
var image: UIImage? = UIImage(named: "arrow_green_down")
var textLeading: CGFloat = 20
var cornerRadius: CGFloat = Constants.borderRadius
var borderWidth: CGFloat = 0
var height: Double = 20
var width: Double = 80
var isHidden = false
var text: String = "Please select a country"
var font = UIFont(size: 15)
var backgroundColor: UIColor = Constants.textFieldBackgroundColor
var textColor: UIColor = Constants.secondaryFontColor
}
}

See our example project on GitHub.