How to make iOS UIToolbar with back/forward arrows on the left

烂漫一生 提交于 2020-01-13 18:38:47

问题


I am trying to place a toolbar above a date picker that has back and forward arrows on the left side of the toolbar. I'd like to do this using standard iOS machinery and not roll out custom buttons to do this. Is this possible? I have attached an image for referral. Thanks in advance!


回答1:


I know you don't want to use custom buttons, and this solution doesn't have custom buttons, but it does have custom icons. I hope it works for you. I have looked all over the place for a solution and did not find anything that Apple built, so I figured I would make my own. This is what it looks like, not identical, but pretty close.

In my method where I make the toolbar, I used this code.

 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:)];

All you need to do is insert the images. I made both retina and non retina in a program called Paint Code.

Maybe this will help someone out.

EDIT 7/16/17 Added the 3x images as well!



来源:https://stackoverflow.com/questions/19058654/how-to-make-ios-uitoolbar-with-back-forward-arrows-on-the-left

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!