romaonthego / REFrostedViewController

iOS 7/8 style blurred view controller that appears on top of your view controller.
MIT License
2.97k stars 494 forks source link

How can I open the menu ONLY from the left edge of the view? #110

Open cfirbuvel opened 9 years ago

cfirbuvel commented 9 years ago

btw thank you for this cool app it help me alot with my final project

ghost commented 9 years ago

Same Here!

mkeremkeskin commented 9 years ago

this is how I did it for right edge.

- (void)panGestureRecognized:(UIPanGestureRecognizer *)sender
{
    if ([sender locationInView:self.view].x > self.view.frame.size.width * 0.8 || self.frostedViewController.isVisible) {
        // Dismiss keyboard (optional)
        //
        [self.view endEditing:YES];
        [self.frostedViewController.view endEditing:YES];

        // Present the view controller
        //
        [self.frostedViewController panGestureRecognized:sender];
    }
}
cfirbuvel commented 9 years ago

but what is "self.frostedViewController.isVisible"?

did you add another property?

mkeremkeskin commented 9 years ago

Yeah sorry to mention that I have forgotten about it. In order to understand whether the the menu is visible I have added a method. I wrote it down you can use it.

I have added the line to REFrostedViewController.h
- (bool)isVisible;

line to REFrostedViewController.m
- (bool) isVisible{
    return _visible;
} 

On my above code I'm controlling the right 20% of the screen from right edge. self.frostedViewController.isVisible this is required to continue the pangesture if the menu is visible.

ricsantos commented 9 years ago

Thanks @mkeremkeskin for the inspiration. I have implemented it slightly different (don't need the isVisible logic) for the left side:

if ([sender locationInView:self.view].x < self.view.width * 0.2 || sender.state != UIGestureRecognizerStateBegan) {
    [self.frostedViewController panGestureRecognized:sender];
}