개발자 Q&A

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

2025.04.17 14:39

UIDrawTextFont::getUnderlineThickness에 대한 질문

목록
  • 백엔드도령 6일 전 2025.04.17 14:39
  • 12
    1
저는 iOS 개발을 공부 중입니다.
UIDrawTextFont클래스의 getUnderlineThickness 메소드에 관한 질문을 드리겠습니다.

이 메소드는 글자 밑줄의 두께를 반환하는 메소드입니다.
하지만 이 메소드는 어떤 상황에서 사용해야 할까요?
또한, 이 메소드는 어떤 값을 반환할 수 있을까요?

예를 들어, 글자 밑줄의 두께를 1.0, 2.0, 3.0 등으로 설정할 수 있을까요?

혹시 이 메소드의 사용 예시나 코드를 알려주시면 감사하겠습니다.

    댓글목록

    profile_image
    나우호스팅  6일 전



    UIDrawTextFont 클래스의 getUnderlineThickness 메소드는 글자 밑줄의 두께를 반환하는 메소드입니다. 하지만 이 메소드는 현재 iOS 개발에서 사용할 수 없습니다.

    iOS 13 이상부터는 UIFontDescriptor 클래스의 underlineStyle 속성을 사용하여 글자 밑줄의 두께를 설정할 수 있습니다.

    예를 들어, UIFontDescriptor 클래스의 underlineStyle 속성을 사용하여 글자 밑줄의 두께를 설정할 수 있습니다.

    #hostingforum.kr
    swift
    
    let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body)
    
    fontDescriptor = fontDescriptor.withSymbolicTraits(.underline)
    
    let font = UIFont(descriptor: fontDescriptor, size: 17)
    
    


    또한, UIFontDescriptor 클래스의 underlineStyle 속성은 다음과 같은 값을 반환할 수 있습니다.

    - .none : 글자 밑줄이 없음
    - .single : 단일 밑줄
    - .double : 이중 밑줄

    #hostingforum.kr
    swift
    
    let fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body)
    
    fontDescriptor = fontDescriptor.withSymbolicTraits(.underline)
    
    let font = UIFont(descriptor: fontDescriptor, size: 17)
    
    print(fontDescriptor.underlineStyle) // .single
    
    


    이러한 방법으로 UIFontDescriptor 클래스의 underlineStyle 속성을 사용하여 글자 밑줄의 두께를 설정할 수 있습니다.

    2025-04-17 14:40

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

검색

게시물 검색