日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UINavigationBar 上面添加多个按钮

發(fā)布時(shí)間:2025/5/22 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UINavigationBar 上面添加多个按钮 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

http://xiaohui3837843.blog.163.com/blog/static/54388740201111615432445/

此方法已經(jīng)驗(yàn)證,可行

UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 150, 45)];?
[tools setTintColor:[self.navigationController.navigationBar tintColor]];?
[tools setAlpha:[self.navigationController.navigationBar alpha]];?
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];

UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd?
??????????????????????? target:self action:@selector(clickSettings:)];

UIBarButtonItem *anotherButton1 = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UITabBarSystemItemContacts?
??????????????????????????????????????????????????????? target:self action:@selector(clickEdit:)];?
[buttons addObject:anotherButton];?
[anotherButton release];?
[buttons addObject:anotherButton1];?
[anotherButton1 release];?
[tools setItems:buttons animated:NO];?
[buttons release];?
UIBarButtonItem *myBtn = [[UIBarButtonItem alloc] initWithCustomView:tools];?
self.navigationItem.rightBarButtonItem = myBtn;

[myBtn release];?
[tools release];

?

?

?

http://blog.sina.com.cn/s/blog_677089db0100um5p.html

次方法驗(yàn)證,暫時(shí)不可行,沒查明原因

UIView * rightButtonParentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
?

rightButtonParentView.backgroundColor = [UIColor clearColor];
?? ?
?? ?int buttonSize = 32;
?? ?int rightOffset = 20;
?? ?UIButton * setButton = [[UIButton alloc] initWithFrame:CGRectMake(rightButtonParentView.frame.size.width - buttonSize - rightOffset, 6, buttonSize, buttonSize)];
?? ?[setButton setBackgroundImage:[UIImage imageNamed:@"star.png"] forState:UIControlStateNormal];
?? ?[setButton addTarget:self action:@selector(NSlog) forControlEvents:UIControlEventTouchUpInside];
?? ?[rightButtonParentView addSubview:setButton];
?? ?[setButton release];
?? ?
?? ?UIButton * searchButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 6, buttonSize, buttonSize)];
?? ?[searchButton setBackgroundImage:[UIImage imageNamed:@"star.png"] forState:UIControlStateNormal];
?? ?[searchButton addTarget:self action:@selector(NSlog) forControlEvents:UIControlEventTouchUpInside];
?? ?[rightButtonParentView addSubview:searchButton];
?? ?[searchButton release];
?? ?
?? ?
?? ?UIBarButtonItem * rightButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButtonParentView];
?? ?[rightButtonParentView release];?? ??? ??? ??? ??? ??? ??? ?
?? ?self.navigationItem.rightBarButtonItem = rightButtonItem;
?? ?[rightButtonItem release];

?

轉(zhuǎn)載于:https://www.cnblogs.com/worldworld/archive/2012/04/16/2451658.html

總結(jié)

以上是生活随笔為你收集整理的UINavigationBar 上面添加多个按钮的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。