以下是我在工具栏下显示UIView
的代码。通过单击工具栏上的按钮显示它。现在我想向弹出的UIView
添加一个按钮,以便取消它。如果可能的话,导航栏上方的按钮会使UI更好?
任何人都可以指点我的教程吗?
-(void)likeButton:(UIBarButtonItem *)button
{
CGRect frame = CGRectMake(0, 480, 320, 190);
frame.origin.y = CGRectGetMaxY(self.optionsToolBar.frame)-frame.size.height;
bottomView.frame = frame;
[self.optionsToolBar.superview insertSubview:bottomView
belowSubview:self.optionsToolBar];
}
答案 0 :(得分:2)
-(void)likeButton:(UIBarButtonItem *)button
{
CGRect frame = CGRectMake(0, 480, 320, 190);
frame.origin.y = CGRectGetMaxY(self.optionsToolBar.frame)-frame.size.height;
bottomView.frame = frame;
UIView *navigationView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[navigationView setBackgroundColor:[UIColor blueColor]];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"close" forState:UIControlStateNormal];
[button addTarget:self action:@selector(closeView:) forControlEvents:UIControlEventTouchUpInside];
[navigationView addSubView:button];
[bottomView addSubView:navigationView];
[self.optionsToolBar.superview insertSubview:bottomView
belowSubview:self.optionsToolBar];
}
- (void) closeView :(id)sender{
[[sender superView] removeFromSuperView];
}