0

下面是我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];
 }
4

1 回答 1

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];          
  }
于 2013-02-08T09:15:57.633 回答