Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 스위프트
- 리팩토링
- swift documentation
- clean architecture
- Observable
- SWIFT
- swiftUI
- HIG
- map
- ribs
- 애니메이션
- 클린 코드
- 리펙터링
- Human interface guide
- Refactoring
- UICollectionView
- Xcode
- MVVM
- ios
- uitableview
- Clean Code
- UITextView
- combine
- uiscrollview
- RxCocoa
- Protocol
- 리펙토링
- tableView
- collectionview
- rxswift
Archives
- Today
- Total
김종권의 iOS 앱 개발 알아가기
[iOS - swift] font 편리하게 사용 방법 (enum) 본문
Font 패밀리 이름을 가지고 enum으로 만들어 사용
- font.regular로 접근할 수 있도록 정의
enum Font: String {
case Regular = "myFont-Regular"
case Bold = "myFont-Bold"
func of(size: CGFloat) -> UIFont {
return UIFont(name: self.rawValue, size: size)!
}
static func regular(size: CGFloat) -> UIFont {
return Font.Regular.of(size: size)
}
static func bold(size: CGFloat) -> UIFont {
return Font.Bold.of(size: size)
}
}
- 사용
Font.regular(size: 12)
Font.bold(size: 16)
'iOS 응용 (swift)' 카테고리의 다른 글
[iOS - swift] textField의 placeholder색깔 변경 방법 (0) | 2021.03.09 |
---|---|
[iOS - swift] mp4, gif 파일 재생 방법 (애니메이션, AVPlayer, Gifu 프레임워크) (0) | 2021.03.04 |
[iOS - swift] attributedText, NSMutableAttributedString (원하는 문자열 속성 지정, 문자열 attributedText 반환) (0) | 2021.03.03 |
[iOS - swift] App Thinning, ODR, App Slicing, bitcode 개념 (0) | 2021.03.01 |
[iOS - swift] enum Equatable 비교 연산자 만드는 방법 (0) | 2021.02.23 |
Comments