如何令Backios barbuttonitemm只有箭头,而没有文本

cmfcribbonstatusbar怎么设置文本_百度知道
cmfcribbonstatusbar怎么设置文本
提问者采纳
/&#47,则会显示出来:UIOffsetMake(0.icon]:tabBarItem被选中没效果;3:actionMenustatusBar字体为白色在plist里面设置View controller-based status bar appearance 为 NO:取消ios7自带手势,则需要&#47:UIBarMetricsDefault];ios7设置BarButtonItem字体颜色.selectedImage = actionM设置BarButtonItem颜色,包括返回箭头[[UINavigationBar appearance] setTintC4://bg_navbar.navigationBar setBackgroundImage:actionMenu:navigationbar上面的BarButtonItem字看不见问题;] forBarPosition;设置statusBarStyle 为 UIStatusBarStyleLightContent2,backBarItem箭头没有;6;ios7的方法viewController:[UIImage imageNamed.selectedIcon withFinishedUnselectedI&#47.png&兼容ios7以前[viewController.tabBarItem:UIBarMetricsDefault]:UIBarPositionTopAttached barMetrics.tabBarItem setFinishedSelectedImage:设置statusBar和navigationbar为一体[nav:刷新状态栏statusBar[self setNeedsStatusBarAppearanceUpdate]5;&#47:@&quot,不包括返回箭头[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment.selectedI&#47:[UIColor whiteColor]],需要调用sdk7中的方法, 0) forBarMetrics
来自团队:
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Add a back arrow to leftBarButtonItem? [添加一个箭头leftbarbuttonitem回来?] - 问题-字节技术
Add a back arrow to leftBarButtonItem?
添加一个箭头leftbarbuttonitem回来?
问题 (Question)
I want to add a back arrow to a leftBarButtonItem, to make it appear visually as if it was a regular back button, although it's functionality is slightly different.
Is there a way to do this?
我想加一回箭一leftBarButtonItem,使它出现视觉上如果它是一个普通的后退按钮,虽然它的功能是不同的。有没有一种方法做这件事吗?
最佳答案 (Best Answer)
You can use custom button and hide the back button if you are using navigation controller.
To hide back button use this:
self.navigationItem.hidesBackButton = YES;
And for Custom Button:
UIButton * customButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customButton setBackgroundColor:[UIColor colorWithRed:197.0/255.0 green:190.0/255.0 blue:157.0/255.0 alpha:1.0]];
[customButton setTitle:@"Do Something" forState:UIControlStateNormal];
customButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:11.0f];
[customButton.layer setCornerRadius:3.0f];
[customButton.layer setMasksToBounds:YES];
[customButton.layer setBorderWidth:1.0f];
[customButton.layer setBorderColor: [[UIColor grayColor] CGColor]];
customButton.frame=CGRectMake(0.0, 100.0, 50.0, 25.0);
[customButton addTarget:self action:@selector(customMethod:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem * customItem = [[UIBarButtonItem alloc] initWithCustomView:customButton];
customItem.tintColor=[UIColor blackColor];
self.navigationItem.leftBarButtonItem = customI
This will work for you.
Happy Coding
您可以使用自定义按钮,如果您使用的是导航控制器背部隐藏按钮。隐藏按钮使用这个:self.navigationItem.hidesBackButton = YES;
和自定义按钮:UIButton * customButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customButton setBackgroundColor:[UIColor colorWithRed:197.0/255.0 green:190.0/255.0 blue:157.0/255.0 alpha:1.0]];
[customButton setTitle:@"Do Something" forState:UIControlStateNormal];
customButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:11.0f];
[customButton.layer setCornerRadius:3.0f];
[customButton.layer setMasksToBounds:YES];
[customButton.layer setBorderWidth:1.0f];
[customButton.layer setBorderColor: [[UIColor grayColor] CGColor]];
customButton.frame=CGRectMake(0.0, 100.0, 50.0, 25.0);
[customButton addTarget:self action:@selector(customMethod:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem * customItem = [[UIBarButtonItem alloc] initWithCustomView:customButton];
customItem.tintColor=[UIColor blackColor];
self.navigationItem.leftBarButtonItem = customI
这将为你工作。快乐的编码
答案 (Answer) 2
If you are using UINavigationController and then push new viewcontroller it will automatically show back button.
If you are Not Using UINavigationController than
Use Custom UIButton for that with back image
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 0, 48, 37);
[backButton addTarget:self action:@selector(backButtonTapped) forControlEvents:UIControlEventTouchUpInside];
backButton.showsTouchWhenHighlighted = YES;
UIImage *backButtonImage = [UIImage imageNamed:@"back-button.png"];
[backButton setImage:backButtonImage forState:UIControlStateNormal];
backButton.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backBarButtonI
You can change the value for the frame and the imageEdgeInsets as per your requirements.
SO Answer.
如果您使用的是uinavigationcontroller再推新viewcontroller它会自动显示后退按钮。如果你不uinavigationcontroller比使用自定义的UIButton,图像UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 0, 48, 37);
[backButton addTarget:self action:@selector(backButtonTapped) forControlEvents:UIControlEventTouchUpInside];
backButton.showsTouchWhenHighlighted = YES;
UIImage *backButtonImage = [UIImage imageNamed:@"back-button.png"];
[backButton setImage:backButtonImage forState:UIControlStateNormal];
backButton.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backBarButtonI
您可以更改框架和imageedgeinsets按您的要求的价值。参见所以答案。
本文翻译自StackoverFlow,英语好的童鞋可直接参考原文:点击backBarButtonItem时消息怎样拦截?
[问题点数:40分,结帖人travelchina2008]
点击backBarButtonItem时消息怎样拦截?
[问题点数:40分,结帖人travelchina2008]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2015年4月 移动开发大版内专家分月排行榜第二
2015年5月 移动开发大版内专家分月排行榜第三2015年3月 移动开发大版内专家分月排行榜第三2014年10月 移动开发大版内专家分月排行榜第三
匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。[ios]使用图像为 backBarButtonItem 的的没有文字
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.
我只想为我导航控制器到此图像设置 backBarButtonItem
而不是苹果默认箭头按钮的标题是前一视图控制器标题相同。最近我到目前为止已经是水平方向上拉伸以标题仍然出现叠加的上述图像。要得到它,我在我的 AppDelegate 使用此代码。
UIImage *backButtonImage = [UIImage imageNamed:@"back-button.png"];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
我如何能去掉的标题 (和阻止按钮被拉伸)?
解决方法 1:
您可以设置自定义图像 BarbuttonItem 像:-
- (void)viewDidLoad
UIImage* imageRight = [UIImage imageNamed:@"Home_btn.png"];
CGRect frameimgRight = CGRectMake(100, 100, 50, 30);
RightBtn = [[UIButton alloc] initWithFrame:frameimgRight];
[RightBtn setBackgroundImage:imageRight forState:UIControlStateNormal];
[RightBtn addTarget:self action:@selector(ActionhomeBtn)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *btnRight = [[UIBarButtonItem alloc]initWithCustomView:RightBtn];
self.navigationItem.leftBarButtonItem = btnR
[super viewDidLoad];
看起来就像:-
希望其扶了起来的你

我要回帖

更多关于 leftbarbuttonitem 的文章

 

随机推荐