Skip to content

Commit

Permalink
Animate UIVisualEffectView
Browse files Browse the repository at this point in the history
  • Loading branch information
cockscomb committed Feb 7, 2016
1 parent d2556d6 commit 76174ce
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions HUDKit/Classes/HUDPresentationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class HUDPresentationController: UIPresentationController {
return view
}()

private lazy var HUDView: UIView = {
let visualEffectView = UIVisualEffectView(effect: self.HUDVisualEffect)
private lazy var HUDView: UIVisualEffectView = {
let visualEffectView = UIVisualEffectView()
visualEffectView.frame = self.frameOfPresentedViewInContainerView()
visualEffectView.layer.cornerRadius = self.cornerRadius
visualEffectView.layer.masksToBounds = self.cornerRadius != 0.0
Expand Down Expand Up @@ -91,13 +91,19 @@ public class HUDPresentationController: UIPresentationController {
NSLayoutConstraint.activateConstraints(constraints)

presentingViewController.transitionCoordinator()?.animateAlongsideTransition({ context in
self.HUDView.effect = self.HUDVisualEffect
self.dimmingView.alpha = 1.0
self.presentingViewController.view.tintAdjustmentMode = .Dimmed
}, completion: nil)
}

public override func dismissalTransitionWillBegin() {
presentingViewController.transitionCoordinator()?.animateAlongsideTransition({ context in
if #available(iOS 9.0, *) {
self.HUDView.effect = nil
} else {
// UIVisualEffectView.effect animation isn't available in iOS 8
}
self.dimmingView.alpha = 0.0
self.presentingViewController.view.tintAdjustmentMode = .Automatic
}, completion: nil)
Expand Down

0 comments on commit 76174ce

Please sign in to comment.