
UIFont.Weight은 FontDescriptor에 포함된 Style에 따라 달라지지 않습니다. 대신, Weight은 FontDescriptor에 포함된 Weight 값과 Style 값이 조합된 결과입니다.
Weight 값은 다음 기준에 따라 결정됩니다.
- ultraLight: 100
- thin: 200
- light: 300
- regular: 400
- medium: 500
- semibold: 600
- bold: 700
- heavy: 800
- black: 900
예를 들어, UIFont.Weight.regular은 FontDescriptor에 포함된 Weight 값이 400인 경우에 해당합니다.
UIDrawTextFontDescriptor::getWeight 메서드는 FontDescriptor에 포함된 Weight 값을 반환합니다. 예를 들어, 다음 코드는 UIFont.Weight.regular을 반환합니다.
#hostingforum.kr
swift
let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body)
let weight = fontDescriptor.fontAttributes[.weight]
print(weight) // 400
2025-07-04 18:26