better animation

This commit is contained in:
nixzhu
2015-11-10 15:05:39 +08:00
parent 3fd4ed42c4
commit 1fe144b487
2 changed files with 21 additions and 0 deletions
@@ -2817,8 +2817,10 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi
vc.previewImageViewInitalFrame = frame
vc.previewImage = image
transitionView?.alpha = 0
vc.afterDismissAction = { [weak self] in
self?.view.window?.makeKeyAndVisible()
transitionView?.alpha = 1
}
mediaPreviewWindow.rootViewController = vc
@@ -77,14 +77,26 @@ class MediaPreviewViewController: UIViewController {
//let finalWidth = UIScreen.mainScreen().bounds.width
//let finalHeight = UIScreen.mainScreen().bounds.height
view.backgroundColor = UIColor.clearColor()
mediasCollectionView.alpha = 0
mediaControlView.alpha = 0
UIView.animateWithDuration(1.25, delay: 0.0, options: .CurveEaseInOut, animations: { [weak self] in
self?.view.backgroundColor = UIColor.blackColor()
self?.previewImageView.frame = CGRect(x: 0, y: (viewHeight - previewImageViewHeight) * 0.5, width: previewImageViewWidth, height: previewImageViewHeight)
}, completion: { [weak self] _ in
self?.mediasCollectionView.alpha = 1
UIView.animateWithDuration(0.25, delay: 0.0, options: .CurveEaseInOut, animations: { [weak self] in
self?.mediaControlView.alpha = 1
}, completion: nil)
self?.previewImageView.alpha = 0
})
@@ -99,10 +111,17 @@ class MediaPreviewViewController: UIViewController {
func dismiss() {
previewImageView.alpha = 1
mediasCollectionView.alpha = 0
UIView.animateWithDuration(0.25, delay: 0.0, options: .CurveEaseInOut, animations: { [weak self] in
self?.mediaControlView.alpha = 0
}, completion: nil)
UIView.animateWithDuration(1.25, delay: 0.0, options: .CurveEaseInOut, animations: { [weak self] in
self?.view.backgroundColor = UIColor.clearColor()
self?.previewImageView.frame = self?.previewImageViewInitalFrame ?? CGRectZero
}, completion: { [weak self] _ in