분류 전체보기 88

컬렉션뷰에서 현재 섹션의 너비에 구애받지 않고 horizontal scroll

let section = NSCollectionLayoutSection(group: group) section.orthogonalScrollingBehavior = .continuous 현재 섹션의 너비에 구애받지 않고 horizontal scroll하려면 orthogonalScrollingBehavior을 .continous로 해주면 된다. 그러면 좌우로 스크롤이 가능해진다. 속성을 .groupPaging으로 바꿔주면 옆으로 스크롤 할 때 페이지를 넘기는 애니메이션으로 끊어지면서 보여진다.

🍎 Apple/UIKit 2022.10.18

[Swift] DateFormatter을 사용하여 string을 date형식으로 변환하기

//2022-10-3 >> 10/3 func formattingDateString(_ dateString: String) -> String { let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd " if let date = formatter.date(from: dateString) { formatter.dateFormat = "M/d" return formatter.string(from: date) } else { return "" } } https://developer.apple.com/documentation/foundation/dateformatter Apple Developer Documentation developer.apple..

🍎 Apple/Swift 2022.10.13

양수 음수에 따라 textColor 변경

함수 사용 textLabel.textColor = convertDiffColor(dif: money) func convertDiffColor(dif: Double) -> UIColor { guard dif > 0 else { return .systemBlue } return .systemRed } double타입인 money를 인자로 받아 연산하여 textColor을 변환한다. 0보다 크면 systemRed를, 0보다 작으면 .systemBlue로 표시한다. 삼항연산자 사용 diffLabel.textColor = stock.diff > 0 ? .systemRed : .systemBlue // (조건) ? (true일때) : (false일때)

🍎 Apple/Swift 2022.10.12