(기록용)
이번에는 UIView animate를 사용하여 애니메이션 효과를 주도록 하겠습니다~~
UIView animate 문서는 아래 링크를 참고하세요
url: developer.apple.com/documentation/uikit/uiview/1622418-animate
예시)
class func animate(withDuration duration: TimeInterval, animations: @escaping () -> Void)
자 이제 간단히 테스트를 진행해보겠습니다.
먼저 효과를 줄 UIView 를 스토리보드에 생성하고, 아웃렛 변수를 추가합니다.
아웃렛 변수 추가를 완료했으면, 효과를 주도록 하겠습니다.
viewDidLoad()안에 아래 소스코드 추가
[UIView .animate(withDuration: 1.0 , animations: {
self.logo_iamge.alpha = 0;
})
]
UI 이미지가 사라지는 효과 적용!
이제 반복되는 효과를 적용하겠습니다.
[UIView .animate(withDuration: 1.0 ,delay: 1.0, options: .repeat, animations: {
self.logo_iamge.alpha = 0;
})
]
반복되지만, 뭔가 부자연스럽죠??
그럼 조금 더 자연스럽게 옵션을 주도록 하겠습니다!
[UIView .animate(withDuration: 1.5 ,delay: 0, options: [.repeat, .autoreverse], animations: {
self.logo_iamge.alpha = 0;
})
]
이렇게 하면 조금 더 자연스러운 효과를 줄 수 있습니다.
더 다양한 옵셥은 아래 링크 참고
url: developer.apple.com/documentation/uikit/uiview/animationoptions
[ios] Swift 원형 이미지 만들기 (0) | 2020.09.25 |
---|