개발자 Q&A

개발하다 막혔다면? 여기서 질문하세요! 초보부터 고수까지, 함께 고민하고 해결하는 공간입니다. 누구나 자유롭게 질문하고 답변을 남겨보세요!

2025.07.04 18:25

UIDrawTextFontDescriptor::getWeight에 대한 질문

목록
  • 노드장인 12일 전 2025.07.04 18:25
  • 30
    1
저는 UIKit의 UIDrawTextFontDescriptor에 대해 공부중인데, getWeight 메서드에 대해 궁금합니다.

getWeight 메서드는 FontDescriptor에 포함된 Weight 값을 반환합니다. 하지만 Weight 값은 어떻게 계산되는지 정확히 모르겠습니다.

Weight는 FontDescriptor에 포함된 Style에 따라 달라지나요?

또한, Weight는 몇 가지 종류가 있나요?

예를 들어, UIFont.Weight.ultraLight, UIFont.Weight.thin, UIFont.Weight.light, UIFont.Weight.regular, UIFont.Weight.medium, UIFont.Weight.semibold, UIFont.Weight.bold, UIFont.Weight.heavy, UIFont.Weight.black 이 있습니다.

이 Weight 값들은 어떤 기준에 따라 결정되나요?

혹시 UIDrawTextFontDescriptor::getWeight에 대한 더 자세한 정보나 예제가 있을까요?

    댓글목록

    profile_image
    나우호스팅  12일 전



    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

  • 개발자 Q&A 포인트 정책
      글쓰기
      50P
      댓글
      10P
  • 전체 36,420건 / 7 페이지

검색

게시물 검색