【问题标题】:Back-like arrow on iOS 7iOS 7 上的后退箭头
【发布时间】:2013-12-19 17:59:14
【问题描述】:

我需要在我的应用程序中添加一个左栏按钮项目,它看起来像系统后退按钮,但不是系统后退按钮,因为它会出现在视图控制器上,这是我的导航控制器堆栈的唯一 vc 并执行我自己的代码。简单地写“Back”对我来说并不是很好,因为我还需要显示“

【问题讨论】:

标签: ios uinavigationbar uinavigationitem


【解决方案1】:

您可以为此使用任何 Unicode 字符(代码中的任何位置)。

你可以在这里找到你想要的:

Xcode > 编辑 > 特殊字符...

搜索 arrowback 或浏览类别。
然后将字符复制粘贴到需要的位置(在 XIB 对象的标题中或在 setTitlesetText 方法中,就像任何其他字符一样

类似:

【讨论】:

  • 在 unicode 中没有箭头看起来像后面的那个(至少不是那个大小)。
  • @johnyu :截取您所期望的内容并将其添加到您的问题中
  • 好的,我添加了图片
  • @johnyu : 嗯.. 我看到了一些,但唯一的问题是,将标题设置为“〈 Back”会暴露“”和“Back”之间的细微偏差。无论如何......我会检查一些好的东西
  • 我可能只需要使用那个箭头的图像。但是感谢您的帮助。
【解决方案2】:

试试这个:

// 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。定位和清晰度的一些改进:(1) CGRectMake(-12, -1, 20, 30), (2) arrowLabel.font = [UIFont systemFontofSize:40], (3) MakeScale(0.65,1.25)。
【解决方案3】:

考虑使用虚拟UIViewController 作为UINavigationController 堆栈的根视图控制器:

 [[UINavigationController alloc] initWithRootViewController:[UIViewController new]];
 [navController pushViewController:viewController animated:NO];

然后您可以使用我的BackButtonHandler 扩展来处理返回按钮操作(如this thread 中所述):

 -(BOOL) navigationShouldPopOnBackButton {
      [self dismissModalViewControllerAnimated:YES];
      return NO; 
 }

【讨论】:

    【解决方案4】:

    查看 UIBarButtonItem 文档中 contants 下的 UIBarButtonSystemItem 枚举:

    https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UIBarButtonItem_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40007519-CH3-SW2

    这些都是 Apple 提供的按钮样式:

    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;
    

    也许倒带或撤消对您来说已经足够接近了。

    【讨论】:

    • 不幸的是,它们完全不同。
    猜你喜欢
    • 2013-08-25
    • 2013-09-27
    • 1970-01-01
    • 1970-01-01
    • 2015-12-02
    • 2021-01-14
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多