diff --git a/CircularRevealKit.podspec b/CircularRevealKit.podspec index c6b3571..44af834 100644 --- a/CircularRevealKit.podspec +++ b/CircularRevealKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'CircularRevealKit' - s.version = '0.9.2' + s.version = '0.9.3' s.summary = 'Circular reveal animations made easy' s.homepage = 'https://github.com/T-Pro/CircularRevealKit' s.description = 'This library was created to allow developers to implement the material design reveal effect.' diff --git a/CircularRevealKit/Classes/UICircularViewControllerExtension.swift b/CircularRevealKit/Classes/UICircularViewControllerExtension.swift index cac575c..002d1d4 100644 --- a/CircularRevealKit/Classes/UICircularViewControllerExtension.swift +++ b/CircularRevealKit/Classes/UICircularViewControllerExtension.swift @@ -115,115 +115,119 @@ public extension UIViewController { let fromViewController: UIViewController? = transactionContext.viewController( forKey: UITransitionContextViewControllerKey.from) - if let toView: UIView = toViewController?.view, - let fromView: UIView = fromViewController?.view, - let toViewSnapshot: UIView = toView.snapshotView(afterScreenUpdates: true), - let fromViewSnapshot: UIView = fromView.snapshotView(afterScreenUpdates: true) { + guard let toView: UIView = toViewController?.view, + let fromView: UIView = fromViewController?.view else { + return + } - let fadeView: UIView? = self.buildFadeView(fadeColor, fromView.frame) - - switch revealType { - - case RevealType.reveal: + toView.isHidden = false + transactionContext.containerView.insertSubview( + toView, + aboveSubview: fromView) - fromViewSnapshot.isOpaque = true - fromViewSnapshot.isHidden = true - transactionContext.containerView.addSubview(fromViewSnapshot) + guard let toViewSnapshot: UIView = toView.snapshotView(afterScreenUpdates: true), + let fromViewSnapshot: UIView = fromView.snapshotView(afterScreenUpdates: true) else { + return + } - DispatchQueue.main.asyncAfter(deadline: .now()) { + let fadeView: UIView? = self.buildFadeView(fadeColor, fromView.frame) - if let fadeView: UIView = fadeView { - fadeView.alpha = 0.01 - transactionContext.containerView.addSubview(fadeView) - } + switch revealType { - toViewSnapshot.isHidden = true - transactionContext.containerView.addSubview(toViewSnapshot) + case RevealType.reveal: - transactionContext.containerView.insertSubview( - toView, - aboveSubview: fromView) + fromViewSnapshot.isOpaque = true + fromViewSnapshot.isHidden = true + transactionContext.containerView.addSubview(fromViewSnapshot) - toViewSnapshot.layoutIfNeeded() - fromViewSnapshot.layoutIfNeeded() + DispatchQueue.main.asyncAfter(deadline: .now()) { - UIView.animate(withDuration: animationTime) { - fadeView?.alpha = 1.0 - } + if let fadeView: UIView = fadeView { + fadeView.alpha = 0.01 + transactionContext.containerView.addSubview(fadeView) + } - toViewSnapshot.drawAnimatedCircularMask( - startFrame: rect, - duration: animationTime, - revealType: revealType) { () -> Void in + toViewSnapshot.isHidden = true + transactionContext.containerView.addSubview(toViewSnapshot) - DispatchQueue.main.asyncAfter(deadline: .now()) { - completion(true) - transitionCompletion?() - fromViewSnapshot.removeFromSuperview() - fadeView?.removeFromSuperview() - toViewSnapshot.removeFromSuperview() - } + toViewSnapshot.layoutIfNeeded() + fromViewSnapshot.layoutIfNeeded() - } + UIView.animate(withDuration: animationTime) { + fadeView?.alpha = 1.0 + } - fromViewSnapshot.isHidden = false - toViewSnapshot.isHidden = false - fadeView?.isHidden = false + toViewSnapshot.drawAnimatedCircularMask( + startFrame: rect, + duration: animationTime, + revealType: revealType) { () -> Void in - } + DispatchQueue.main.asyncAfter(deadline: .now()) { + completion(true) + transitionCompletion?() + fromViewSnapshot.removeFromSuperview() + fadeView?.removeFromSuperview() + toViewSnapshot.removeFromSuperview() + toView.isHidden = false + } - case RevealType.unreveal: + } - toViewSnapshot.isOpaque = true - toViewSnapshot.isHidden = true - transactionContext.containerView.addSubview(toViewSnapshot) + fromViewSnapshot.isHidden = false + toViewSnapshot.isHidden = false + fadeView?.isHidden = false - DispatchQueue.main.asyncAfter(deadline: .now()) { + } - if let fadeView: UIView = fadeView { - fadeView.alpha = 1.0 - fadeView.isHidden = true - transactionContext.containerView.addSubview(fadeView) - } + case RevealType.unreveal: - fromViewSnapshot.isHidden = true - transactionContext.containerView.addSubview(fromViewSnapshot) + toViewSnapshot.isOpaque = true + toViewSnapshot.isHidden = true + transactionContext.containerView.addSubview(toViewSnapshot) - // toView.isHidden = true - transactionContext.containerView.insertSubview( - toView, - belowSubview: fromView) + DispatchQueue.main.asyncAfter(deadline: .now()) { - toViewSnapshot.layoutIfNeeded() - fromViewSnapshot.layoutIfNeeded() + if let fadeView: UIView = fadeView { + fadeView.alpha = 1.0 + fadeView.isHidden = true + transactionContext.containerView.addSubview(fadeView) + } - UIView.animate(withDuration: animationTime) { - fadeView?.alpha = 0.01 - } + fromViewSnapshot.isHidden = true + transactionContext.containerView.addSubview(fromViewSnapshot) - fromViewSnapshot.drawAnimatedCircularMask( - startFrame: rect, - duration: animationTime, - revealType: revealType) { () -> Void in + transactionContext.containerView.insertSubview( + toView, + belowSubview: fromView) - DispatchQueue.main.asyncAfter(deadline: .now()) { - completion(true) - transitionCompletion?() - fromViewSnapshot.removeFromSuperview() - fadeView?.removeFromSuperview() - toViewSnapshot.removeFromSuperview() - fromViewController?.view.removeFromSuperview() - toView.isHidden = false - } + toViewSnapshot.layoutIfNeeded() + fromViewSnapshot.layoutIfNeeded() - } + UIView.animate(withDuration: animationTime) { + fadeView?.alpha = 0.01 + } - fromViewSnapshot.isHidden = false - toViewSnapshot.isHidden = false - fadeView?.isHidden = false + fromViewSnapshot.drawAnimatedCircularMask( + startFrame: rect, + duration: animationTime, + revealType: revealType) { () -> Void in + + DispatchQueue.main.asyncAfter(deadline: .now()) { + completion(true) + transitionCompletion?() + fromViewSnapshot.removeFromSuperview() + fadeView?.removeFromSuperview() + toViewSnapshot.removeFromSuperview() + fromViewController?.view.removeFromSuperview() + toView.isHidden = false + } } - + + fromViewSnapshot.isHidden = false + toViewSnapshot.isHidden = false + fadeView?.isHidden = false + } } diff --git a/Example/CircularRevealKit/SecondViewController.swift b/Example/CircularRevealKit/SecondViewController.swift index 07a255a..f510811 100644 --- a/Example/CircularRevealKit/SecondViewController.swift +++ b/Example/CircularRevealKit/SecondViewController.swift @@ -35,6 +35,23 @@ class SecondViewController: UIViewController { return view }() + internal lazy var navigationBar: UINavigationBar = { + let view = UINavigationBar() + view.translatesAutoresizingMaskIntoConstraints = false + view.backgroundColor = UIColor.blue + let navigationItem: UINavigationItem = UINavigationItem() + navigationItem.title = "SecondViewController" + view.items = [navigationItem] + return view + }() + + internal lazy var bottomBar: UIView = { + let view = UIView() + view.translatesAutoresizingMaskIntoConstraints = false + view.backgroundColor = UIColor.green + return view + }() + deinit { print("Deinit SecondViewController") } @@ -44,6 +61,8 @@ class SecondViewController: UIViewController { title = "SecondViewController" view.backgroundColor = UIColor.white view.addSubview(randomButton) + view.addSubview(navigationBar) + view.addSubview(bottomBar) view.updateConstraintsIfNeeded() } @@ -80,6 +99,81 @@ class SecondViewController: UIViewController { multiplier: 1, constant: 0)] view.addConstraints(constraints) + + if #available(iOS 11, *) { + let guide = view.safeAreaLayoutGuide + NSLayoutConstraint.activate([ + navigationBar.topAnchor.constraint(equalToSystemSpacingBelow: guide.topAnchor, multiplier: 1.0), + ]) + } else { + let standardSpacing: CGFloat = 8.0 + NSLayoutConstraint.activate([ + navigationBar.topAnchor.constraint(equalTo: topLayoutGuide.topAnchor, constant: standardSpacing), + ]) + } + + let navigationBarConstraints = [ + NSLayoutConstraint( + item: view!, + attribute: .left, + relatedBy: .equal, + toItem: navigationBar, + attribute: .left, + multiplier: 1, + constant: 0), + NSLayoutConstraint( + item: view!, + attribute: .right, + relatedBy: .equal, + toItem: navigationBar, + attribute: .right, + multiplier: 1, + constant: 0) + ] + + view.addConstraints(navigationBarConstraints) + + if #available(iOS 11, *) { + let guide = view.safeAreaLayoutGuide + NSLayoutConstraint.activate([ + bottomBar.bottomAnchor.constraint(equalToSystemSpacingBelow: guide.bottomAnchor, multiplier: 1.0), + ]) + } else { + let standardSpacing: CGFloat = 8.0 + NSLayoutConstraint.activate([ + bottomBar.bottomAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor, constant: standardSpacing), + ]) + } + + let bottomBarConstraints = [ + NSLayoutConstraint( + item: view!, + attribute: .left, + relatedBy: .equal, + toItem: bottomBar, + attribute: .left, + multiplier: 1, + constant: 0), + NSLayoutConstraint( + item: view!, + attribute: .right, + relatedBy: .equal, + toItem: bottomBar, + attribute: .right, + multiplier: 1, + constant: 0), + NSLayoutConstraint( + item: bottomBar, + attribute: .height, + relatedBy: .equal, + toItem: nil, + attribute: .notAnAttribute, + multiplier: 1, + constant: 44) + ] + + view.addConstraints(bottomBarConstraints) + } super.updateViewConstraints() } diff --git a/Example/Pods/Target Support Files/CircularRevealKit/CircularRevealKit-Info.plist b/Example/Pods/Target Support Files/CircularRevealKit/CircularRevealKit-Info.plist index 1085929..ed250dd 100644 --- a/Example/Pods/Target Support Files/CircularRevealKit/CircularRevealKit-Info.plist +++ b/Example/Pods/Target Support Files/CircularRevealKit/CircularRevealKit-Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.9.2 + 0.9.3 CFBundleSignature ???? CFBundleVersion diff --git a/README.md b/README.md index 473ec16..0b43b17 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ platform :ios, '9.0' use_frameworks! target '' do -pod 'CircularRevealKit', '~> 0.9.2' +pod 'CircularRevealKit', '~> 0.9.3' end ``` @@ -59,7 +59,7 @@ $ brew install carthage To integrate CircularRevealKit into your Xcode project using Carthage, specify it in your `Cartfile`: ```ogdl -github "T-Pro/CircularRevealKit" ~> 0.9.2 +github "T-Pro/CircularRevealKit" ~> 0.9.3 ``` Run `carthage update` to build the framework and drag the built `CircularRevealKit.framework` into your Xcode project.