如何在左侧使用后退/前进箭头制作iOS UIToolbar

时间:2013-09-27 19:29:16

标签: ios objective-c uibarbuttonitem uitoolbar

我正在尝试将工具栏放在日期选择器上方,该工具栏左侧有后退和前进箭头。我想使用标准iOS机器这样做,而不是推出自定义按钮来做到这一点。这可能吗?我附上了一张图片用于推荐。提前谢谢!

Example toolbar with desired <> assets

1 个答案:

答案 0 :(得分:14)

我知道您不想使用自定义按钮,此解决方案没有自定义按钮,但它确实有自定义图标。我希望这个对你有用。我已经到处寻找解决方案而没有找到Apple建造的任何东西,所以我想我会自己创造。这就是它的样子,不完全相同,但非常接近。

enter image description here

在我制作工具栏的方法中,我使用了这段代码。

 previousButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Back.png"]
                                                      style:UIBarButtonItemStyleBordered
                                                     target:self 
                                                     action:@selector(previousField:)];
 nextButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Forward.png"]
                                                  style:UIBarButtonItemStyleBordered
                                                 target:self 
                                                 action:@selector(nextField:)];

您需要做的就是插入图像。我在一个名为Paint Code的程序中制作了视网膜和非视网膜。

也许这会帮助别人。

编辑7/16/17 还添加了3张图片!

enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here