Jimmy's iOS
iOS) Swift 애플산돌고딕네오(AppleSDGothicNeo) 폰트 적용하기 본문
Extension 폴더안에 재사용을 위해서 만들어 놓는다.
enum FontType {
case regular, bold, medium, light, semibold
}
//MARK: - UIFont
extension UIFont {
static func fontWithName(type : FontType, size : CGFloat) -> UIFont {
var fontName = ""
switch type {
case .regular: fontName = "AppleSDGothicNeo-Regular"
case .light: fontName = "AppleSDGothicNeo-Light"
case .medium: fontName = "AppleSDGothicNeo-Medium"
case .semibold: fontName = "AppleSDGothicNeo-SemiBold"
case .bold : fontName = "AppleSDGothicNeo-Bold"
}
return UIFont(name: fontName, size: size) ?? UIFont.systemFont(ofSize: size)
}
}
원하는 곳에서 사용 예시)
let infoText : UILabel = {
let label = UILabel()
label.text = "테스트"
label.textColor = .blackColor
label.numberOfLines = 0
label.textAlignment = .center
label.font = UIFont.fontWithName(type: .medium, size: 16)
return label
}()
'iOS' 카테고리의 다른 글
iOS) Lottie-Animation 적용하기 (0) | 2021.09.22 |
---|---|
iOS) 앱 최신버전 체크 및 업데이트 하러 가기 (0) | 2021.09.14 |
iOS) CATransition 을 사용하여 뷰 컨트롤러 fade in , fade out 시키기 (0) | 2021.07.19 |
iOS) 키보드 올라오고 내려갈시 화면 올리기 , 내리기 (0) | 2021.07.14 |
iOS) 화면 터치하여 키보드 내리는 방법 (0) | 2021.07.08 |