Avatar
treastrain / Tanaka.R 3/5/2021 5:07 AM
@swift-5.3.3 import Foundation let formatter = NumberFormatter() formatter.numberStyle = .decimal print("1:", formatter.string(from: 100)) // Optional("100") formatter.formatWidth = 6 print("2:", formatter.string(from: 100)) // Optional(" 100") formatter.paddingPosition = .beforePrefix print("3:", formatter.string(from: 100)) // Optional(" 100") formatter.paddingPosition = .afterPrefix print("4:", formatter.string(from: 100)) // Optional(" 100") formatter.paddingPosition = .beforeSuffix print("5:", formatter.string(from: 100)) // Optional("100 ") formatter.paddingPosition = .afterSuffix print("6:", formatter.string(from: 100)) // Optional("100 ") (edited)