如何将closuresbutton添加到UIModalPresentationPageSheet中提供的模态视图angular?
我想添加一个浮动closures(x)button在UIModalPresentationPageSheet
视图的angular落。 效果如下:
但是,将其添加到父视图使其出现在页面页面(也不可能点击),并将其添加到页面页面将隐藏它的一部分,因为它不在视图区域中。
有没有更好的解决scheme?
任何build议表示赞赏。
您可以尝试将其添加到最上面的应用程序窗口中:
add.modalPresentationStyle = UIModalPresentationPageSheet; [self presentViewController:add animated:YES completion:^{ [[[[UIApplication sharedApplication] windows] lastObject] addSubview:button]; }];
这应该给你正确的看法,让button出现在模态和接收触摸事件的顶部。
– 编辑 –
要定位button,你可以尝试这样的事情:
self.modalPresentationStyle = UIModalPresentationFormSheet; add.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentViewController:pvc animated:YES completion:^{ CGRect parentView = pvc.view.superview.frame; CGRect buttonFrame = button.frame; buttonFrame.origin = CGPointMake(parentView.origin.x - buttonFrame.size.width/2.0f, parentView.origin.y - buttonFrame.size.height/2.0f); [button setFrame:buttonFrame]; [[[[UIApplication sharedApplication] windows] lastObject] addSubview:button]; }];
这将得到已经呈现的modalView的框架。 然后你可以设置你的button的原点偏移,并设置调整的框架。
看看这是否工作:
myPresentedView.clipsToBounds = NO;
这将允许button超出它的意见。 这样做的一个缺点是,触摸不会超出视图范围,所以尽量不要将button设置得太远。