What's New In UIkit

조영민·2022년 6월 8일
0

캘린더가 바뀌었습니다.

기존

View

let now = Date()
let calendar = Calendar.current 

components

let now = Date()
let calendar = Calendar.current
calendar.component(.year, from: now)

신규

UICalendarView

View

UICalendarView ( NSDateComponents )

components

NSCalendar.currentCalendar < property

let calendarView = UICalendarView()
calendarView.delegate = self
calendarView.calendar = Calendar(identifier: .gregorian)
view.addSubview(calendarView)

delegate 메서드

func multiDateSelection(
    _ selection: UICalendarSelectionMultiDate,
    canSelectDate dateComponents: DateComponents
) -> Bool {
    return myDatabase.hasAvailabilities(for: dateComponents)
}

PageControl

페이지 컨트롤이란게 생겼네요.

pageControl.direction = .topToBottom
pageControl.preferredIndicatorImage = UIImage(systemNamed: "square")
pageControl.preferredCurrentIndicatorImage = UIImage(systemNamed: "square.fill")

UIPasteControl

원하는 형태의 sheet 타입 지원

sheet.detents = [
    .large(),
    .custom { _ in
        200.0
    }
]

Content value

Symbol에서 사용 가능합니다.

variableValue (property) -> 0 부터 1 까지
configuration (property) -> configuration 넣어주면 된다.

Self-resizing Cell

UIListContentConfiguration 사용 -> compositional Layout 사용시

알아서 변경합니다.

cell.contentConfiguration 로 접근 가능합니다.

UIHostingConfiguration

UIkit 에서 SwiftUI 코드를 쓸 수 있네요.

cell.contentConfiguration = UIHostingConfiguration {
    VStack {
        Image(systemName: "wand.and.stars")
            .font(.title)
        Text("Like magic!")
            .font(.title2).bold()
    }
    .foregroundStyle(Color.purple)
}

0개의 댓글