DVG
DVG

Reputation: 17480

Inverting UIBarButtonItem "Play" for use as a Back Button?

Okay, simple enough.

I'm coding up a simple web view, and I'm providing a few Safari-like controls for navigation.

Play seems to be the obvious choice for the forward button, but I'd like to have a Back Button as well, as seen in several Apple and third party apps.

Is there a way to invert the icon, so that it points backwards, or are all the apps using this setup using images to replicate this functionality?

Upvotes: 5

Views: 1945

Answers (3)

Chris
Chris

Reputation: 1539

I know this was answered long ago, however just to add...

Yes, you can use Unicode but it does not look the same as the standard ios button. And if you have strict requirements to match ios look than you will need to at least make an image for the back button, in this case by simply downloading the play image and flipping it.

UIImage *image = [UIImage imageNamed:@"backButton.png"];
UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeCustom];
[btnBack setImage:image forState:UIControlStateNormal];
btnBack.frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);

UIBarButtonItem * btnItem = [[UIBarButtonItem alloc] initWithCustomView:btnBack];
[btnItem addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
// add it to your bar
self.navigationItem.leftBarButtonItem = btnItem;

(wrote it without spell checking... so beware of spelling errors that may have resulted)

// button images are here. http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html

Upvotes: 1

Tal Bereznitskey
Tal Bereznitskey

Reputation: 2051

Unicode is your friend here.

Create a UIBarButtonItem (in Interface Builder or in code) and set it to "Custom" where you can enter text for the button.

Now use these Unicode characters to simulate the back & forward buttons:

◄ and ►

I use it in my apps and it looks great.

Upvotes: 13

Christopher Pickslay
Christopher Pickslay

Reputation: 17772

You could use atPeek to extract the play button png from an app that uses it, and then use any image manipulation program to flip it.

Upvotes: 0

Related Questions