【问题标题】:iOS 7 Back Button Arrow Vertical AlignmentiOS 7后退按钮箭头垂直对齐
【发布时间】:2013-09-27 21:46:44
【问题描述】:

在 iOS 7 上,有没有办法改变后退按钮箭头的垂直对齐方式?我只能更改标题的垂直对齐方式,UIBarButtonItem 的外观中没有任何内容表明可以更改箭头垂直对齐方式。

看下面的例子:

【问题讨论】:

  • 你能给我们一些截图吗?
  • [button setContentHorizontalAlignment:][button setContentVerticalAlignment:] 应该做你想做的事。如果您直接访问 titleLabel 属性来设置对齐方式,那将是您的问题。
  • [[UIBarButtonItem 外观] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, 10) forBarMetrics:UIBarMetricsDefault];
  • OP 正在调整 箭头 位置,而不是标题

标签: uibarbuttonitem ios7 back-button appearance


【解决方案1】:

我认为实现目标的最佳方式是将UINavigationBars backIndicatorImage设置为箭头图像,并在其周围留有空间。您可以遮盖您的图像,以便文本能够流入图像的某些部分。

UINavigationBar *navigationBar = ...;

navigationBar.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Activity" style:UIBarButtonItemStylePlain target:nil action:nil];

navigationBar.backIndicatorImage = [UIImage imageNamed:@"arrow-image"];
navigationBar.backIndicatorTransitionMaskImage = [UIImage imageNamed:@"arrow-image-mask"];

AppCoda 写了一篇关于在 iOS7 中自定义 UINavigationBar 的精彩文章。值得一读:
http://www.appcoda.com/customize-navigation-status-bar-ios-7/

正如文档所说,您必须设置 BOTH 属性才能启动和运行:https://developer.apple.com/library/ios/documentation/uikit/reference/uinavigationbar_class/Reference/UINavigationBar.html#//apple_ref/occ/instp/UINavigationBar/backIndicatorImage

【讨论】:

  • 你的意思是:“嘿亚伦”。 Ashley 没有问这个问题
猜你喜欢
  • 2013-08-25
  • 1970-01-01
  • 2013-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多