UI 글꼴 - 시스템 얇은 글꼴을 가져오는 방법
UIFont
일반 글꼴을 얻을 수 있는 방법이 있습니다(systemFontOfSize
) 또는 굵은 글꼴(boldSystemFontOfSize
), 하지만 스토리보드를 통해 "씬 시스템 글꼴"을 사용할 수 있는 방법은 무엇입니까?
시스템 씬(thin) 전달UIFont
생성자가 작동하지 않습니다. 이 생성자는 시스템이 아닌 글꼴에 대해서만 작동합니다.
시스템 글꼴 얇은 무게를 사용할 수 있습니다.
UIFont.systemFont(ofSize: 34, weight: UIFontWeightThin)
샌프란시스코의 사용 가능한 중량 목록:
UIFontWeightUltraLight
UIFontWeightThin
UIFontWeightLight
UIFontWeightRegular
UIFontWeightMedium
UIFontWeightSemibold
UIFontWeightBold
UIFontWeightHeavy
UIFontWeightBlack
iOS 11 기준으로. UIFontWeight*
로 이름이 변경되었습니다.UIFont.Weight.*
. 여기 https://developer.apple.com/documentation/uikit/uifont.weight 에서 더 많은 정보를 얻을 수 있습니다.
iOS 8.2부터는 사용이 가능합니다.UIFont.systemFontOfSize(_ fontSize: CGFloat, weight weight: CGFloat)
:
UIFont.systemFontOfSize(19, weight: UIFontWeightLight)
iOS SDK는 가중치에 대한 상수를 제공했습니다.
UIFontWeightUltraLight
UIFontWeightThin
UIFontWeightLight
UIFontWeightRegular
UIFontWeightMedium
UIFontWeightSemibold
UIFontWeightBold
UIFontWeightHeavy
iOS가 iOS에서 시스템 글꼴을 변경할 수 있으므로 시스템 글꼴을 사용할 때 시스템 글꼴을 사용하는 것이 시스템 글꼴 이름에 따라 글꼴을 만드는 것보다 낫습니다(iOS 7의 경우 Helvetica Neue, 현재 iOS 9의 경우 San Francisco).
그래서 제가 제안하고 싶은 것은 당신이 원하는 폰트의 TTF 파일을 커스텀 폰트로 사용하고 당신의 앱에서 커스텀 폰트를 사용하는 것입니다.
이것이 제가 애플을 좋아하지 않는 특별한 이유입니다. 절대. 사과의 뜻대로 되다항상 우리가 하고 싶은 대로 해요. 애플은 계속 바뀝니다. 모든 OS의 기본 글꼴입니다.
또한 동일한 글꼴 크기를 유지하고 무게만 변경하려면 대상 요소 글꼴 크기에서 사용합니다.예를 들어,
demoLabel.font = UIFont.systemFont(ofSize: demoLabel.font.pointSize, weight: UIFontWeightThin)
이것을 사용하면 기본 라벨 글꼴 크기를 유지하고 가중치만 변경할 수 있습니다.
iOS 11부터 UIFontWeightThin은 다음으로 이름이 변경되었습니다.UIFont.Weight.thin
. 여기 https://developer.apple.com/documentation/uikit/uifont.weight 에서 더 많은 정보를 얻을 수 있습니다.
스위프트 4.2 / 스위프트 5.0
label.font = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.thin)
언급URL : https://stackoverflow.com/questions/31771679/uifont-how-to-get-system-thin-font
'programing' 카테고리의 다른 글
민첩한 업로더 워드프레스 구현 (0) | 2023.10.29 |
---|---|
자바스크립트를 통해 CSS 사용자 지정 속성(일명 CSS 변수) 접근 (0) | 2023.10.29 |
뒤로 가기 단추에서 텍스트를 변경하는 방법 (0) | 2023.10.29 |
리소스를 로드하고 해당 리소스의 내용을 봄에 문자열로 사용하는 방법 (0) | 2023.10.29 |
mysql storage-procedure: out 매개변수 (0) | 2023.10.29 |