Skip to content

Commit

Permalink
feat: update swift example
Browse files Browse the repository at this point in the history
  • Loading branch information
HeathWang committed Sep 6, 2019
1 parent 03a1c0e commit fccf42c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
10 changes: 7 additions & 3 deletions SwiftDemo/ControllerExample/App/ShoppingCartController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class ShoppingCartViewController: UIViewController {
view.addGestureRecognizer(tapGes)
}

override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}

@objc func didTapAction() {
dismiss(animated: true, completion: nil)
}
Expand All @@ -37,16 +41,16 @@ extension ShoppingCartViewController {
return PanModalHeight(type: .content, height: 512)
}

override func shouldAnimatePresentingVC() -> Bool {
return true
override func presentingVCAnimationStyle() -> PresentingViewControllerAnimationStyle {
return .shoppingCart
}

override func showDragIndicator() -> Bool {
return false
}

override func transitionDuration() -> TimeInterval {
return 1.2
return 1.0
}

override func springDamping() -> CGFloat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class MyCustomAnimationViewController: UIViewController {
view.backgroundColor = UIColor(displayP3Red: 0.600, green: 1.000, blue: 0.600, alpha: 1)
}

override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}

}

extension MyCustomAnimationViewController {
Expand All @@ -31,18 +35,14 @@ extension MyCustomAnimationViewController {
return 0
}

override func shouldAnimatePresentingVC() -> Bool {
return true
override func presentingVCAnimationStyle() -> PresentingViewControllerAnimationStyle {
return .custom
}

override func customPresentingVCAnimation() -> PanModalPresentingViewControllerAnimatedTransitioning? {
return customAnimation
}

override func panModalGestureRecognizer(_ panGestureRecognizer: UIPanGestureRecognizer, dismissPercent percent: CGFloat) {
let scale = 0.9 + percent * 0.1
presentingViewController?.view.transform = CGAffineTransform(scaleX: scale, y: scale)
}
}

fileprivate class MyCustomAnimation: NSObject, PanModalPresentingViewControllerAnimatedTransitioning {
Expand All @@ -56,11 +56,8 @@ fileprivate class MyCustomAnimation: NSObject, PanModalPresentingViewControllerA
}

func dismissTransition(context transitionContext: PanModalPresentingViewControllerContextTransitioning) {
let duration = transitionContext.mainTransitionDuration()
let VC = transitionContext.viewController(forKey: .to)
UIView.animate(withDuration: duration) {
VC?.view.transform = CGAffineTransform.identity
}
VC?.view.transform = CGAffineTransform.identity
}

}
4 changes: 2 additions & 2 deletions SwiftDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down

0 comments on commit fccf42c

Please sign in to comment.