0

我有这个返回 UIBarButtonItem 的方法,我想要不可见的按钮,但是当有人点击它时工作,,,,,

- (UIBarButtonItem *)leftMenuBarButtonItem {

UIBarButtonItem *barbuttonitem = [[UIBarButtonItem alloc]
                                  initWithImage:[UIImage imageNamed:@"bacbbutton.png"] style:UIBarButtonItemStyleDone
                                  target:self
                                  action:@selector(leftSideMenuButtonPressed:)];


return barbuttonitem;
}

我怎样才能使这个按钮不可见,但是每当使用点击那个角落或导航栏时,按钮就会起作用,但可见性应该被隐藏......

4

2 回答 2

1

将按钮设置为hidden将意味着它不能被点击。您只想将其设置为透明。您需要通过创建具有自定义视图的条形按钮项并将视图设置alpha为零来执行此操作。自定义视图将是一个UIButton.

于 2013-06-06T06:07:25.273 回答
1
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setImage:[UIImage imageNamed:@"bacbbutton.png"] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(leftSideMenuButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
btn.alpha = 0.3;
UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithCustomView:btn];
于 2013-06-06T06:09:43.267 回答