我需要在我的应用程序中添加一个看起来像系统后退按钮的左栏按钮项,但不是系统后退按钮,因为它会出现在视图控制器上,这是唯一的vc我的navController的堆栈并执行我自己的代码。简单地写“返回”对我来说并不好,因为我需要显示“<”箭头。有没有办法以编程方式创建一个这样的箭头,而没有使用该箭头形象?下的UIBarButtonItem文档中contantsiOS 7上的背向箭头
回答
考虑使用虚拟UIViewController
作为根鉴于您的UINavigationController
的栈控制器:
[[UINavigationController alloc] initWithRootViewController:[UIViewController new]];
[navController pushViewController:viewController animated:NO];
然后你可以使用我BackButtonHandler扩展处理后退按钮的动作(如this thread描述):
-(BOOL) navigationShouldPopOnBackButton {
[self dismissModalViewControllerAnimated:YES];
return NO;
}
看那UIBarButtonSystemItem
枚举:
这些都是由苹果公司提供的按钮样式:
typedef enum {
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
UIBarButtonSystemItemUndo, // iOS 3.0 and later
UIBarButtonSystemItemRedo, // iOS 3.0 and later
UIBarButtonSystemItemPageCurl, // iOS 4.0 and later
} UIBarButtonSystemItem;
也许倒带或撤消将足够接近你。
不幸的是,它们是完全不同的东西。 – johnyu
对此,您可以使用任何Unicode字符(代码中的任意位置)。
你可以找到你想要的这里:
的Xcode>编辑>特殊字符...
搜索arrow
或back
或浏览的类别。
然后复制粘贴(在XIB对象的标题,或在setTitle
或setText
方法像任何其他字符)
东西等,其中所需要的字符:
unicode中没有箭头,看起来像后面的箭头(至少不是那种大小)。 – johnyu
@johnyu:截取你期望的内容并将其添加到你的问题 – staticVoidMan
好吧,我添加了图像 – johnyu
试试这个:
// After you create and place your backButton:
UILabel* arrowLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, 20, 20)];
arrowLabel.text = @"<";
arrowLabel.textColor = [backButton titleColorForState:UIControlStateNormal];
arrowLabel.transform = CGAffineTransformMakeScale(1,2);
[backButton addSubview:arrowLabel];
如果addSubview给你添麻烦了,请尝试
[backButton insertSubview:arrowLabel atIndex:0];
- 1. setDisplayHomeAsUpEnabled()+向上箭头?
- 2. iOS 7 - UIPopoverController:弃用的箭头?
- 3. html向上向下箭头
- 4. Python中的向上箭头?
- 5. 带方向箭头的背景
- 6. 想要向上/向下箭头输入iOS的HTML数字
- 7. AutoCompleteComboBox箭头向上/向下箭头键滚动列表
- 8. 如何检测iOS上的图像中向上的箭头?
- 9. 向上和向下箭头的JavaScript
- 10. 方向箭头
- 11. .keyup()向上和向下箭头在Safari
- 12. 禁用向上和向下箭头
- 13. 用向上/向下箭头选择div
- 14. 按下右箭头使向上箭头被设置
- 15. 防止向下箭头或向上箭头更新MS Access中的组合框
- 16. iPhone方向箭头?
- 17. jquery sticked向上和向下箭头向上和向下
- 18. 如何发送LeftShift和向上箭头或向下箭头在C#
- 19. 特定方向的箭头
- 20. 指向箭头的阴谋
- 21. 向下箭头的HTML
- 22. AS3:setSelection向上箭头覆盖
- 23. C++调整QScrollBar向上箭头
- 24. 向上箭头键带有Pexpect,Python
- 25. 检测为双方向上和向右C++,向上箭头
- 26. 在iOS中绘制箭头背后的数学运算
- 27. Windows 7的地图CTRL + J键向下箭头键
- 28. 如何设置与背景微调箭头下拉箭头?
- 29. 窗口7 64位:使用shift +向下箭头和ctrl + shift +向左箭头移动光标,但不选择
- 30. UIApplicationState活跃在背景上的iOS 7
可能重复[创建在UIToolbar上左箭头按钮(就像UINavigationBar的“后退”风格)](http://stackoverflow.com/questions/227078/creating-a-left-arrow-button-like-uinavigationbars-back-style-on-a -uitoolba) –
请注意,建议的重复是一个更老的问题,约会到2008年,只有[一个答案](http://stackoverflow.com/a/18874211/643383)与iOS 7相关。此外,OP在这里特别提出为解决方案不同于那一个答案中描述的解决方案。让我们不要太快把它作为一个副本来关闭它。 – Caleb