You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct CardView:View{// MARK: - PROPERTIES@StateprivatevarimageNumber:Int=1// 기본값을 넣지 않으면 사용처에서 넣어야함 @StateprivatevarrandomNumber:Int=1@StateprivatevarisShowingSheet:Bool= false
// MARK: - FUNCTIONSfunc randomImage(){print("--- BUTTON WAS PRESSED ---")print("Status: Old Image Number = \(imageNumber)")
repeat {
randomNumber =Int.random(in:1...5)print("Action: Random Number Generated = \(randomNumber)")} while randomNumber == imageNumber
imageNumber = randomNumber
print("Result: New Image Number = \(imageNumber)")print("--- THE END ---")print("\n")}var body:someView{// MARK: - CARDZStack{CustomBackgroundView()VStack{// MARK: - HEADERVStack(alignment:.leading){HStack{Text("Hiking")Spacer()Button{
isShowingSheet.toggle()} label:{CustomButtonView()}}Text("Fun and enjoyable outdoor activity for friends and families.")}// MARK: - MAIN CONTENTZStack{Button{// ACTION: Generate a random numberrandomImage()} label:{}//: ZSTACK}//: CARD.frame(width:320, height:570)}}structCardView_Previews:PreviewProvider{staticvarpreviews:someView{CardView()}}
Animation
Image("image-\(imageNumber)").resizable().scaledToFit().animation(.default, value: imageNumber)// imageNumber가 다르면 바로 애니메이션
Overflow hidden하는법
Zstack { }.mask(Circle()) 이렇게 mask를 추가하면 된다.
고성능 렌더링
.drawingGroup
고성능 렌더링을 위한 modifier offscreencanvas와 비슷한 것 같음
title: Swift UI
full_path: pages/iOS/swift.md
Swift UI에서 Color 자동완성하는 법
우선 asset에 색상을 정의해주어야함 그리고 swift 파일을 만들고 다음과 같이 작성
Color.customGreenLight
형태로 자동완성이 가능하다.ReUsable Button 만들기
swift파일을 만든다. view파일 아님
실제 사용 코드
상태관리
Animation
Overflow hidden하는법
Zstack { }.mask(Circle()) 이렇게 mask를 추가하면 된다.
고성능 렌더링
.drawingGroup
고성능 렌더링을 위한 modifier offscreencanvas와 비슷한 것 같음
BottomSheet 올리기
컴포넌트 인자 Optional하게 주기
아래와 같이 ? operator와 nil 주기
The text was updated successfully, but these errors were encountered: