我已将第三方库导入到我的项目中,我将其称为来自我原始项目的appDelegate的主ViewController。我正在尝试添加backButton(不更改第三方库的代码)。
我在AppDelegate中使用以下
呈现VCABSViewController *abs = [[ABViewController alloc] init];
[self.window.rootViewController presentViewController:abs
animated:NO
completion:nil];
然后我尝试用下面的程序方式添加我的UIButton,但即使调用了“带有子视图”,也不会出现在前面。
UIButton *backButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
backButton.layer.backgroundColor = [UIColor blueColor].CGColor;
[abs.view addSubview:backButton];
[abs.view bringSubviewToFront:backButton];
我可以看到按钮是在presentViewController动画完成之前创建的,但它是在ABSViewController(库ViewController)后面设置的
答案 0 :(得分:1)
我认为你需要在presentViewController
ABSViewController *abs = [[ABViewController alloc] init];
[self presentViewController:viewController animated:YES completion:^{
UIButton *backButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
backButton.layer.backgroundColor = [UIColor blueColor].CGColor;
[abs.view addSubview:backButton];
[abs.view bringSubviewToFront:backButton];
}];