我想在导航栏上放置一个"i"按钮(在导航栏出现的所有屏幕上).触摸该按钮应该会显示一个视图(可能是模态),我可以在其中进行控制.如何将按钮放在导航栏上,以及如何执行回叫?
Jor*_*dan 65
信息按钮代码:
UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(infoButtonAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *modalButton = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
[self.navigationItem setLeftBarButtonItem:modalButton animated:YES];
[modalButton release];
Run Code Online (Sandbox Code Playgroud)
上面的代码调用方法 - (void)infoButtonAction.将其添加到所有ViewControllers或只创建一个.nib并将其用于所有视图.
Ilk*_*aci 10
您也可以在storyboard上实现它.将UIButton拖到导航栏而不是通常的UIBarButtonItem.您将看到您的解开按钮将"嵌套"在可以展开的栏按钮项内.
然后,您可以将按钮的类型属性更改为info light | 属性检查器中的黑暗.
归档时间: |
|
查看次数: |
9599 次 |
最近记录: |