SWRevealViewController
SWRevealViewController copied to clipboard
darken front view when rear view is open
is there any way to do this? ( if there is code i would prefer swift if possible.. thanks)
Yes, create a view: (here I am in a subclass of SWRevealViewController)
var coverView: UIView?
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
self.tapGestureRecognizer()
self.panGestureRecognizer()
coverView = UIView(frame: UIScreen.mainScreen().bounds)
coverView?.backgroundColor = UIColor.lightGrayColor().colorWithAlphaComponent(0.25)
}
...
//MARK: - SWRevealViewControllerDelegate
func revealController(revealController: SWRevealViewController!, willMoveToPosition position: FrontViewPosition) {
if position == FrontViewPosition.Right {
self.frontViewController.view.userInteractionEnabled = false
self.frontViewController.view.addSubview(coverView!)
}
else {
self.frontViewController.view.userInteractionEnabled = true
coverView!.removeFromSuperview()
}
}
You are a GOD!
thank you
Thanks, I forgot for the rotation:
coverView?.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
thanks it is helpful~~~~