일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
- mac
- MacOS
- 개발자
- SwiftUI
- window
- appstore
- Code
- 이미지
- Apple
- Session
- Firebase
- 웹뷰
- UIButton
- darkmode
- rxswift
- error
- github
- Git
- Swift
- Archive
- FLUTTER
- view
- 한글
- Xcode
- Realm
- Notification
- JPA
- iOS16
- geofencing
- IOS
- Today
- Total
목록boundingRect (2)
EEYatHo 앱 깎는 이야기
boundingRect Swift에는 NSString, NSAttributedString를 감싸는 CGRect를 계산해주는 메소드가 있다. extension NSString { // ... @available(iOS 7.0, *) open func boundingRect(with size: CGSize, options: NSStringDrawingOptions = [], attributes: [NSAttributedString.Key : Any]? = nil, context: NSStringDrawingContext?) -> CGRect } extension NSAttributedString { // ... @available(iOS 6.0, *) open func boundingRect(with siz..
개발을 하다보면 Label 의 줄 수에 따라서 조건이 변하는 경우가 생기는데, 대부분의 경우 AutoLayout으로 해결하지만, 줄 수에 따라 분기해야하는 경우도 발생합니다. text와 font를 가지고 , 미리 줄의 수를 알 수 있는 방법이 있습니다. class Utilities { ... /* UILabel의 줄 수를 return 합니다. label : .text와 .font를 설정해준 채로 보내줘야합니다. labelWidth : 한 줄의 넓이입니다. */ class func lineNumber(label: UILabel, labelWidth: CGFloat) -> Int { let boundingRect = label.text!.boundingRect(with: .zero, options: [.us..