Arman
Arman

Reputation: 856

Mobile Safari-style back button for UIWebView?

I haven't been able to find any sort UIBarButtonSystemItem representing tha "Back" button in Mobile Safari. I want my UIWebView's controls to look just like the ones in Mobile Safari so it makes sense. Would the best solution be to just screenshot UIBarButtonSystemItemPlay (same image as the Forward button) and flip it?

Thanks.

Upvotes: 12

Views: 12654

Answers (6)

ff10
ff10

Reputation: 3147

I just made them for myself, basically they are exact copies (don't count the pixels though). You may use them in any way you like, commercially or not. Just don't try to sell them please.

[File removed, iOS 7 introduced a whole new look for those buttons.]

Upvotes: 23

Tsuneo Yoshioka
Tsuneo Yoshioka

Reputation: 7874

If I just use unicode for left-pointing triangle @"\U000025C0", it uses Apple Color Emoji. To use simple symbol without color, use unicode variation selector for text style emoji("\U0000FE0E").

So, string for the left-pointing triangle is @"\U000025C0\U0000FE0E".

I think this is the matter only on iPhone Simulator(on Mountain Lion supporting unicode 6.1), and does not cause problem on actual device, yet.

Upvotes: 2

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: 8

Steven David
Steven David

Reputation: 704

I had the same problem but have found a very nice solution:

http://outerlevel.com/blog/2008/12/26/code-example-drawing-the-iphone-back-button/

But you have to change some values

as the following:

CGContextBeginPath(context);
CGContextMoveToPoint(context, 8.0f, 12.0f);
CGContextAddLineToPoint(context, 24.0f, 3.0f);
CGContextAddLineToPoint(context, 24.0f, 21.0f);
CGContextClosePath(context);
CGContextFillPath(context);

only a little tweak from me because the back button was not aligned to the forward button, back button was 1px too high. btw should I make this to community Wiki ? im new here ...

Upvotes: 4

chrisbtoo
chrisbtoo

Reputation: 1572

I think the right move is to try and find the raw icon somewhere (try Terminal, and find in your /Developer directory).

It's possible that

/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/Applications/WebSheet.app/ArrowBack.png

is the right file.

Just taking a screenshot isn't going to work, as the toolbar icons are based on alpha levels rather than colours. If you grab a screenshot and flip it, you'll just end up with a solid square for your button.

Upvotes: 8

Brian Postow
Brian Postow

Reputation: 12187

I'm not sure how iPhone apps are packaged, but if you can open the .app folder and poke around, you should be able to find the actual image file in there in the resources folder...

Upvotes: 0

Related Questions