Menu Slider programmatically

Asked

Viewed 64 times

0

I’m creating a menu programmatically, I instate the menu in my home and when I click the button that will pull the menu, the menu appears but I can’t interact, I can’t click the cells, who is with the priority is the home and not the menu, how do I so that when I click the button and pull the menu it gets the priority?

- (void)viewDidLoad {

    [super viewDidLoad];

    menuViewone =[[UIView alloc ]initWithFrame:CGRectMake(0, 0, 0, 568)];
    [menuViewone setBackgroundColor:[UIColor blackColor]];
    [self.view addSubview:menuViewone];

    menuViewController = [[ITMenuViewController alloc] init];
    menuViewController.view.frame = CGRectMake(0, 0, 0, 568);
    [self.view addSubview:menuViewController.view];

    btn = [[UIButton alloc] init];

    btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn addTarget:self action:@selector(pushMenu) forControlEvents:UIControlEventTouchUpInside];
    [btn setTitle:@"push" forState:UIControlStateNormal];
    btn.frame = CGRectMake(40, 300, 240, 40);
    [btn setBackgroundColor:[UIColor orangeColor]];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    btn.layer.cornerRadius = 2;
    btn.tag = 1;
    btn.clipsToBounds = YES;
    //set other button properties here.
    [self.view addSubview:btn];

}

- (void)pushMenu {
    if (menuViewController.view.frame.origin.x < 0 && btn.tag == 2) {
        [UIView animateKeyframesWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{

            self.view.frame = CGRectMake(0, 0, 320, 568);
            menuViewController.view.frame=CGRectMake(0, 0, 0, 568);


        } completion:^(BOOL finished) {

            btn.tag = 1;

        }];
    }

    if (menuViewController.view.frame.origin.x >= 0 && btn.tag == 1)
    {
        [UIView animateKeyframesWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{


            self.view.frame = CGRectMake(200, 0, 320, 568);
            menuViewController.view.frame=CGRectMake(-self.view.frame.size.width + 0, 0, self.view.frame.size.width, 568);
            [self.view.layer setCornerRadius:4];
            [self.view.layer setShadowColor:[UIColor blackColor].CGColor];
            [self.view.layer setShadowOpacity:0.8];
            [self.view.layer setShadowOffset:CGSizeMake(0.0f, 2.5f)];


        } completion:^(BOOL finished) {

            btn.tag = 2;

        }];
    }
}
  • Are you using a library? How are you opening the menu? Any code to show us? Add some information to that effect that will facilitate aid.

  • I added the code

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.