Ali*_*Ali 14 iphone objective-c ios
我想创建一个acustom导航栏.
我知道我们可以在导航栏中间使用UIButton而不是标题,但是我们可以制作看起来像这张照片的东西吗?
如您所见,此导航栏中间有三个不同的按钮.您能否与我分享您的想法,我们如何在iPhone中实现这样的功能?
Kel*_*ler 17
假设您使用的是导航控制器,您可以将navigationBar的titleView属性设置为UIView容器,该容器中间有三个按钮(以及两组三个点).代码看起来像这样:
UIView *buttonContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
buttonContainer.backgroundColor = [UIColor clearColor];
UIButton *button0 = [UIButton buttonWithType:UIButtonTypeCustom];
[button0 setFrame:CGRectMake(0, 0, 44, 44)];
[button0 setBackgroundImage:[UIImage imageNamed:@"button0.png"] forState:UIControlStateNormal];
[button0 addTarget:self action:@selector(button0Action:) forControlEvents:UIControlEventTouchUpInside];
[button0 setShowsTouchWhenHighlighted:YES];
[buttonContainer addSubview:button0];
//add your spacer images and button1 and button2...
self.navigationItem.titleView = buttonContainer;
Run Code Online (Sandbox Code Playgroud)
或者你当然可以在IB中完成这一切.
| 归档时间: |
|
| 查看次数: |
11100 次 |
| 最近记录: |