如何将导航栏和UIButton添加到从底部滑动的UIView

时间:2013-02-08 08:25:26

标签: iphone uiview

以下是我在工具栏下显示UIView的代码。通过单击工具栏上的按钮显示它。现在我想向弹出的UIView添加一个按钮,以便取消它。如果可能的话,导航栏上方的按钮会使U​​I更好? 任何人都可以指点我的教程吗?

-(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];
 }

1 个答案:

答案 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];          
  }