1、使用window 覆盖
2、试图添加到
如果有一个场景:首页三个tab,要求只覆盖Navigation ,而不影响Tab使用,那么使用window 覆盖就不满足了。
这里我们可以使用如下方案:
业务调用
......
[_loginView showInView:self.navigationController.view edgeInsets:UIEdgeInsetsMake(0, 0, bottom, 0) animation:animation];
......
@implementation RPDLoginView ( : UIView)
-(void)showInView:(UIView*)supperView edgeInsets:(UIEdgeInsets)edgeInsets animation:(BOOL)animation{ [supperView addSubview:self]; [self makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(supperView).with.insets(edgeInsets); }]; if (animation) { [_bottomView remakeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.mas_bottom); make.left.right.equalTo(self); make.height.equalTo(@180); }]; [self layoutIfNeeded];//如果其约束还没有生成的时候需要动画的话,就请先强制刷新后才写动画,否则所有没生成的约束会直接跑动画 [UIView animateWithDuration:0.3 animations:^{ [_bottomView remakeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.equalTo(self); make.height.equalTo(@180); }]; [self layoutIfNeeded];//强制绘制 }]; } }