반응형
좌우로 계속해서 흔들리는 Animation 코드
Rectangle()
.frame(width: 100, height: 100)
.foregroundColor(.blue)
.offset(x: xOffset)
.animation(Animation.easeInOut(duration: 0.1).repeatForever(autoreverses: true))
.onAppear {
self.xOffset = -10
}
특정 횟수만큼 흔들리도록 하기 위해서는 repeatForever 대신 repeatCount사용.
반응형
'Dev-iOS > SwiftUI' 카테고리의 다른 글
[SwiftUI] Animation 모음 - (하트 모양 좋아요 버튼) (0) | 2024.09.10 |
---|---|
[SwiftUI] 프로퍼티 래퍼 (Property Wrapper) (0) | 2024.09.09 |
[SwiftUI] QR 코드 만들기 (38) | 2024.05.29 |
하위 뷰에 Localizable.xcstring 적용하기 (23) | 2024.05.28 |
[SwiftUI] @State 값 변경 감시하기 (26) | 2023.07.05 |