问题
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