开发者

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.

开发者_JAVA技巧

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?


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜