Как нарисовать вид наложения поверх UINavigation и UITabBar - PullRequest
0 голосов
/ 26 апреля 2018

Я хочу показать наложение поверх существующих элементов UINavigationBar и UITabBar в нижней части.

Я попытался добавить вид наложения в окне приложения напрямую, но ничего не получилось.

Вот мой пользовательский вид со всеми ограничениями

-(void)showView{
    animationOverlay=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 400, 400)];
    animationOverlay.translatesAutoresizingMaskIntoConstraints=false;

    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    [btn setFrame:CGRectMake(0, 0, 100, 100)];
    [btn setTitle:@"Go" forState:UIControlStateNormal];
    [btn setTranslatesAutoresizingMaskIntoConstraints:false];

    [animationOverlay setBackgroundColor:[UIColor redColor]];

    NSLayoutConstraint *leftConstraint = [NSLayoutConstraint
                                          constraintWithItem:animationOverlay attribute:NSLayoutAttributeLeft
                                          relatedBy:NSLayoutRelationEqual toItem:self.view attribute:
                                          NSLayoutAttributeLeft multiplier:1.0 constant:0];

    NSLayoutConstraint *rightConstraint = [NSLayoutConstraint
                                           constraintWithItem:animationOverlay attribute:NSLayoutAttributeWidth
                                           relatedBy:NSLayoutRelationEqual toItem:self.view attribute:
                                           NSLayoutAttributeWidth multiplier:1.0 constant:0];

    NSLayoutConstraint *topConstraint = [NSLayoutConstraint
                                         constraintWithItem:animationOverlay attribute:NSLayoutAttributeTop
                                         relatedBy:NSLayoutRelationEqual toItem:self.view attribute:
                                         NSLayoutAttributeTop multiplier:1.0 constant:0];

    NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint
                                            constraintWithItem:animationOverlay attribute:NSLayoutAttributeBottom
                                            relatedBy:NSLayoutRelationEqual toItem:self.view attribute:
                                            NSLayoutAttributeBottom multiplier:1.0 constant:0];

    NSLayoutConstraint *centreXConstraint= [NSLayoutConstraint constraintWithItem:btn
                                                                        attribute:NSLayoutAttributeCenterX
                                                                        relatedBy:0
                                                                           toItem:animationOverlay
                                                                        attribute:NSLayoutAttributeCenterX
                                                                       multiplier:1
                                                                         constant:0];

    NSLayoutConstraint *centreYConstraint= [NSLayoutConstraint constraintWithItem:btn
                                                                        attribute:NSLayoutAttributeCenterY
                                                                        relatedBy:0
                                                                           toItem:animationOverlay
                                                                        attribute:NSLayoutAttributeCenterY
                                                                       multiplier:1
                                                                         constant:0];

    [self.view addSubview:animationOverlay];
    [self.view addConstraint:leftConstraint];
    [self.view addConstraint:rightConstraint];
    [self.view addConstraint:topConstraint];
    [self.view addConstraint:bottomConstraint];
    [animationOverlay addSubview:btn];
    [self.view addConstraint:centreXConstraint];
    [self.view addConstraint:centreYConstraint];

}

-(void)hideView{
    [animationOverlay removeFromSuperview];
} 

enter image description here

прямо сейчас я могу сделать это в представлении ViewController успешно

Любые идеи о том, как это сделать ..

Я не мог придумать, как это сделать, не нарушая ограничений

любые идеи, предложения приветствуются

1 Ответ

0 голосов
/ 07 мая 2018

Вы пытались показать VC модально, я думаю, что это покроет панель вкладок и панель навигации:

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion;

Итак, поместите ваш оверлейный вид в другой VC, а затем представьте этот VC из вашего текущего VC, используя presentViewController:

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...