0
我的目标是在我的工具栏中的按钮上创建一个简单的弹窗视图。所以显然苹果不希望我在我的iPhone上创建它。但是我已经看到了其他应用中熟悉的东西。 因此,我不想使用苹果的UIPopOver,而是喜欢创建一个UIView,当单击栏按钮时出现。再次点击时消失。如果我也可以创建指向按钮的小箭头(您知道我指的是哪个箭头:D),那将会是顶级的。但是这个时间不相关。我只是想创建这个“popover出现并且用相同的按钮消失”。我的“解决方案”权利知道是不是一个解决方案:iPhone上的自定义UIView应该看起来像UIPopover
- (IBAction)buttonPressed:(id)sender
{
UIView *myPopOverView = [[UIView alloc] initWithFrame:CGRectMake(25, 25, 500, 250)];
myPopOverView.alpha = 0.0;
myPopOverView.layer.cornerRadius = 5;
myPopOverView.layer.borderWidth = 1.5f;
myPopOverView.layer.masksToBounds = YES;
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(testNSLog)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Show myPopOverView" forState:UIControlStateNormal];
button.frame = CGRectMake(10, 10, 100, 30);
[myPopOverView addSubview:button];
[self.view addSubview:myPopOverView];
[UIView animateWithDuration:0.4 animations:^{
[myPopOverView setAlpha:1.0];
} completion:^(BOOL finished) {}];
}
所以我不知道如何做到这一点与这段代码片段。它就像我想要的那样马上出现。但我不知道如何创建这个切换。我尝试了一个简单的布尔如果切换,但它没有奏效。我真的不知道如何从我的视图中删除它。 你们能帮我解决吗?
在此先感谢!