我有一个要求,我必须在UIPopoverController的弹出视图中显示自定义边框,而不是默认的“黑色主题”边框。有可能吗?
我无法使用默认的黑色边框,因为它不适合应用程序的颜色主题。
SDK中没有规定可以执行此操作。我也用谷歌搜索,看看是否有其他人遇到过这个问题,如果他们已经解决了,但没有运气!
等待建议。
谢谢, 拉吉
答案 0 :(得分:2)
通过使用UIView解决这个问题,并通过覆盖主rootViewController视图中的hitTest来查看触摸点是否在该视图之外。如果是这样,将使用该事件来关闭新的弹出窗口,否则该事件将被转发到新的弹出窗口。
答案 1 :(得分:0)
将popview添加为子视图,代码为:
//!you must define the dimBackgroundView and set view in head file firstly,
//action for a button,to add set view as a subview
- (IBAction)openSetting:(id)sender {
if(!dimBackgroundView)
{
dimBackgroundView = [[UIView alloc] initWithFrame:self.view.bounds];
}
dimBackgroundView.backgroundColor = [[UIColor clearColor] colorWithAlphaComponent:0.0];
[self.view addSubview:dimBackgroundView];
SettingViewController *set = [[SettingViewController alloc]initWithNibName:nil bundle:nil];
[set.view setFrame:CGRectMake(120, 50, 400, 600)];
self.setView = set;
//add shadow
set.view.layer.shadowOffset = CGSizeMake(3, 3);
set.view.layer.shadowColor = [UIColor colorWithRed:70.0/255.0 green:70.0/255.0 blue:80.0/255.0 alpha:1.0].CGColor;
set.view.layer.shadowOpacity = 0.8;
[self.view addSubview:set.view];
}
//check touch position, if touch position is outside of setview, remove it from superview
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event{
UITouch *touch = [[event allTouches] anyObject];
if ([self.setView.view superview] && self.dimBackgroundView == touch.view) {
[self.dimBackgroundView removeFromSuperview];
[self.setView.view removeFromSuperview];
}
}