UIFont-시스템 얇은 글꼴을 얻는 방법
UIFont
일반 글꼴 ( systemFontOfSize
) 또는 굵은 글꼴 ( boldSystemFontOfSize
)을 얻는 방법이 있지만 스토리 보드를 통해 사용할 수있는 "얇은 시스템 글꼴"을 얻는 방법은 무엇입니까?
UIFont
Contructor에 "system-thin"을 전달하는 것은 작동하지 않으며,이 생성자는 시스템 글꼴이 아닌 경우에만 작동합니다.
시스템 글꼴 얇은 두께를 사용할 수 있습니다.
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
Using system font is better than creating a font based on font name when you want to use system fonts since iOS can change their system fonts on iOS (like when they did with Helvetica Neue in iOS 7, and now, San Francisco in iOS 9).
So what I would suggest is to include TTF file of the font you want as use that ttf file as custom font and use the custom font in your app.
This is the special reason why I don't like Apple. Never go what Apple say. Always do what we want. Apple keep on changing Default font for every OS.
Also if you want to keep same font size and just change weight then use from targeted element font size. For example:
demoLabel.font = UIFont.systemFont(ofSize: demoLabel.font.pointSize, weight: UIFontWeightThin)
with this you can keep default label font size and just change weight.
iOS 11부터 UIFontWeightThin의 이름이 UIFont.Weight.thin
. 자세한 내용은 https://developer.apple.com/documentation/uikit/uifont.weight에서 얻을 수 있습니다 .
스위프트 4.2
label.font = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.thin)
참고 URL : https://stackoverflow.com/questions/31771679/uifont-how-to-get-system-thin-font
'development' 카테고리의 다른 글
Android ListView의 하단 구분선 제거 (0) | 2020.08.27 |
---|---|
iOS : 코드에서 app-info.plist 변수에 액세스 (0) | 2020.08.27 |
낙타 케이스 토큰의 단어 사이에 공백 삽입 (0) | 2020.08.27 |
파이썬에서 멋진 열 출력 만들기 (0) | 2020.08.27 |
숭고한 텍스트를 사용하여 특정 문자열 뒤에 줄 바꿈 제거 / 추가 (0) | 2020.08.27 |