You are on page 1of 27

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

RayWenderlich Tutorials for iPhone / iOS Developers and Gamers New blog post by @tdahbura: How To Enable ARC in a Cocos2D 2.X Project http://t.co/hIZCaNrn Store Forums Art Tutorials
English

31 May 2012

Photoshop For Developers: Making a Leather Navigation Bar


This post is also available in: Chinese (Simplified)
Tweet 64

Learn how to make a stylish leather navigation bar - from scratch! This is a blog post by iOS Tutorial Team member Tope Abayomi, an iOS developer and Founder of App Design Vault, your source for iPhone App Design. In this tutorial, youll learn how to make a stylish leather navigation bar for your app, complete with buttons from scratch! Not only will you go through creating the design, youll also export the custom bar and buttons and get them working in a sample Xcode app. The best part is youll be able to re-use the skills youll learn in this tutorial to create all sorts of custom navigation bars in case you want a different look than leather. And to top it off, the end of the tutorial rewards you with a free design-related goodie from App Design Vault! This tutorial is for developers who want to learn a little bit about design. To go through the tutorial, you need to have Xcode and Photoshop. If you do not have Photoshop, you can download a free trial from Adobe. Now before I start making jokes about another kind of leather bar, lets get started!

Getting Started
Open up Photoshop and create a new document with the following settings.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

1/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Use the dimensions 640960 px, which are the retina dimensions for the iPhone. At the end of the tutorial, youll down-scale the design for the non-retina version. To make it easier to integrate a navigation bar with an app, its good to add some guides to help with creating graphics that have the correct dimensions. Drag the ruler onto the document to create a new guide, and let it go when you get to 88 pixels in height. Alternatively, go to View>New Guide, select Horizontal, type 88 for Position, and click OK.

Change the foreground color to #8a5a38 by clicking on the toolbar item with two squares (black and white), and then changing the values to as shown below:

Create a new layer by clicking the New Layer icon in the Layers panel. Go to View>Snap To and make sure Document Bounds and Guides are both checked. This will make creating the shape easier. Select the Rounded Rectangle Tool and give it a radius of 15 pixels. Select the Fill Pixels option. Draw a new shape around the top of the document to form the background of the navigation bar.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

2/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

You should now have a rounded rectangle at the top of the document. The bottom of the navigation bar will be a straight line. To get the straight bottom, use the selection tool, select the area below the guide and hit Cmd-X to delete it.

When editing an item, make sure the corresponding layer is selected in the Layers palette. Otherwise you will edit the layer that is selected rather than the one you intended to edit.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

3/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Adding Depth to the Background


The next step is to add some depth to the background. Right now it looks flat and doesnt feel like a visual element. The way to achieve this effect is by adding layer styles in Photoshop. This tutorial is going to use a lot of layer styles to make shapes come to life. That is the secret of making great designs! Designers are going to hate me for revealing this to you guys :-] The first layer style to add is the inner shadow. Double-click on the brown navigation bar layer in the Layers panel to bring up the Layer Style window. Click on Inner Shadow. Now the box next to Inner Shadow will be checked and you will see all the options for the Inner Shadow style. Use the following options to add an inner shadow style that will simulate the highlights on a top and left side of the leather bar:

Click on Bevel and Emboss and use these options to add a shadow on the bottom and right of the leather bar:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

4/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Click on Gradient Overlay and use these settings to make the bar look rounded:

The navigation bar should look like the image below when you are done adding these styles. Now the bar has more of a 3-dimensional feel to it.

The next step is to add a leather texture to the bar. There are two ways to do this. You could use filters to create a leather texture, or you can download a ready-made texture. Using filters to achieve a leather effect is another tutorial in its own right. However, since I am an efficient (*cough* lazy) developer, I am just going to use a downloaded leather texture. You can buy one from iStockPhoto.com. You can also find a free one at cgtextures.com just go to the Fabric/Leather folder. Heres one that has been desaturated for you to use: click here Open your leather texture in Photoshop. Select all by typing Command-A, and then copy by typing Command-C. Go to your leather bar document and type Command-V to paste it in as a new layer.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

5/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Make sure the new layer is above the brown bar you created earlier in the Layers panel. It will look like the texture is covering up the background, like this:

You want the texture layer to blend with the background, so modify the layer blending mode to Soft Light. Next, command-click on the thumbnail of the brown bar in the Layers panel. This selects the area of the brown bar. Make sure the leather texture layer is still selected in the Layers panel, right-click on the layer, and select Create Clipping Mask. The clipping mask will crop the texture layer using the edges of the brown background, so that the bar remains rounded at the top.

Youre done with the navigation bar background. You could export it as-is and start using it in your app, but youll find that the default bar/back buttons wont look very good with the leather navigation bar. Why dont you create some buttons that will blend nicely? Drag some guides onto the document to form the frame of the bar button.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

6/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Create a new layer. Change the foreground to black and select the Rounded Rectangle Tool again. Change the radius to 10 pixels, and then draw a rectangle within the guides.

Now do some more layer style magic. These layer styles will give the illusion that the button is inset into the navigation bar. Double-click on the layer with the black rectangle, and add a drop shadow style with the following settings. The color of the drop shadow is #9f7357; click on the color box to change it:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

7/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Add an inner shadow style with the following settings. The color of the inner shadow is #664c24, a darker shade of brown than the navigation bar:

Add an outer glow style with the following settings. The color of the glow is white:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

8/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Add an inner glow with the following settings. The color of the inner glow is #3b280b:

Add a color overlay with the following settings. The color of the overlay is #180900:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

9/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Add a gradient overlay with the following settings:

To set the correct gradient, which will go from a lighter to a darker shade of brown, first click on the gradient bar. The gradient settings will pop up.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

10/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Modify the start and end colors by double-clicking on the stops (the triangles below the gradient bar). The left stop should have the color setting #261302 and the right stop #f7ceb3.

After applying all the layer styles, Click OK. Then change the Fill opacity (at the top of the Layers panel) to 0%. This makes it so that only the layer effects show up, and none of the original black background. You will end up with an inset button that looks like the image below:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

11/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Magic, right? Thats what a bunch of layer styles can feel like :-] The next step is to add text to the button. This will be done in the code but is illustrated here to visually complete the design. Click on the text tool and type some text on the document. It will automatically create a new layer. The font used in this case is Helvetica 30 pts.

Add the drop shadow layer style to the text to make look inset into the button. The color of the drop shadow is #4b2f20.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

12/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Drawing the Back Button


The next step is to add the background for the back button. Before you do that, select the button and text layer (hold down Command to select more than one layer), choose the Move tool (type V to use the shortcut for this), and move the layers for the bar button and the Edit text all the way to the right. Create a new layer. Click the Rounded Rectangle Tool and draw a rectangle that almost covers the area defined by the guide.

Select the Polygon Lasso Tool, then use it to select a triangular area by clicking at the three edges.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

13/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Fill the area with a black color: go to Edit->Fill, select Black, and click OK. Now you have the shape for the back button. The same layer styles you used for the bar button item will be used for the back button. Lucky for you, theres no need to go through setting the styles all over again. Simply right-click on the button layer in the Layers panel and choose Copy Layer Style.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

14/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Then select the layer with the back button. Right-click and choose Paste Layer Style.

You should end up with the image below:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

15/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Add a new text layer with the contents Back, and then copy and paste the layer style from the Edit text layer.

Add another text layer for the title of the bar, type the text Preparation and make the font a little bit larger. Copy and paste the layer styles from either of the previous text layers. Now the navigation bar is complete.

Exporting the images


The next step is to export the images so you can use them in an app. A bit later on in the tutorial, youll create a sample app that uses the bars elements in navigation. Make sure you save your document now. Well export the bar background first. Turn off the visibility of the other layers by toggling the eye icon to the left of the layers in the Layer panel. Dont forget the white

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

16/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

background layer as well. Choose the Crop tool.

Select an area around the background layer. Click Enter to commit to the crop.

Save the file as a .PNG by choosing File->Save For Web and Devices. Choose PNG-24 as the type and click Save. Type in the name of your navigation bar, nav-bar.png and click Save. Select the History Palette and go back in the history to the point before you used the Crop Tool.

Turn on the visibility of the back button layer and turn off the others. Use the Crop Tool again to select around the back button and crop the document.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

17/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Save the file as a PNG called back.png. Next you need to make some modifications to the image so it can be used as a resizable/stretchable image in Xcode. The way this works is you set up part of the image to always stay the same, regardless of height/width, and part of the image to repeat itself as necessary to reach any desired height/width. To do this, you need to make some small changes. Instead of an image of the whole button, you only need the left end of the button, a repeatable or stretchable area in the middle, and the right end of the button. Heres how you can make that image: Open back.png, the file you just saved in Photoshop. Select the area in the middle (using the rectangular selection tool, shortcut M) of the image and cut it out by using CmdX:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

18/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Use Selection Tool again to draw a selection around the right side of the image.

Choose the Move Tool and use the left arrow button on your keyboard to move the graphic to the left until it joins the rest of the button on the left.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

19/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Crop out the extra space to the right of the button. Save this image as the back.png. You can replace the previous file with the same name. Do this same process with the bar button. 1) Crop the area around the bar button:

2) Save it as a PNG and re-open it in Photoshop. Select the area in the middle of the image:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

20/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

3) Cut out the selected area and move both images to form an image that can be used as a resizable image:

4) Crop out the empty space:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

21/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Creating Non-Retina Versions


At the moment, all the images youve created are in the retina resolution. To indicate this before you create non-retina versions, rename each of the files nav-bar.png, backbutton.png and bar-button.png so that they have an @2x at the end of the filename. Now open up each of the images in Photoshop and resize them to half the size by going to Image>Image Size, and resizing by 50%. Select the Bicubic Sharper sampling option because we are reducing the image.

Save For Web and Devices again, using a filename without the @2x.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

22/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Using the Images in a Project


Its time to use the current images in a real app that will run on the simulator. Open up Xcode and create a new project with a single view.

Open up the iPhone Storyboard and embed the single view controller in a Navigation Controller:

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

23/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Drag the images you made earlier into your project and make sure to select Copy items into destination groups folder.

Then add the following piece of code to AppDelegate.m in the application:didFinishLaunchingWithOptions:launchOptions method:
UIae*aBrmg =[Img iaeae:"a-a.n"; Img nvaIae UIae mgNmd@nvbrpg] [UNvgtoBrapaac]stakrudmg:aBrmg [Iaiaina perne eBcgonIaenvaIae fraMtisUBrercDfut; oBrerc:IaMtiseal] UIae*aBto =[UIaeiaeae:"a-utnpg]rszbemgWtCpnesUEgIstMk(,5 0 5] Img brutn [Img mgNmd@brbto.n" eialIaeihaIst:Idenesae0 , , ); [UBrutntmapaac]stakrudmg:aBto frtt:IotoSaeoml [IaBtoIe perne eBcgonIaebrutn oSaeUCnrlttNra brerc:IaMtiseal] aMtisUBrercDfut; UIae*akutn=[UIaeiaeae:"akbto.n" rszbemgWtCpnesUEgIstMk(,506] Img bcBto [Img mgNmd@bc-utnpg] eialIaeihaIst:Idenesae01,,); [UBrutntmapaac]stakutnakrudmg:akutnfrtt:IotoSaeoml [IaBtoIe perne eBcBtoBcgonIaebcBto oSaeUCnrlttNra brerc:IaMtiseal] aMtisUBrercDfut;

This uses the UIAppearance API (new in iOS 5) to customize the look of any navigation bars/bar button items in your app with these new textures. For more information on how to use these APIs, check out this tutorial.

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

24/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Run the app in the simulator and you should see a customized navigation bar with the leather effect!

To add the buttons to the bar, change viewDidLoad in ViewController.m to the following:
-(odveDdod vi)iwiLa {

UBrutntm ie =[UBrutntmalc iiWtBrutnytmtmUBrutnytmtmd tre:efato:slco(uheCn IaBtoIe* tm [IaBtoIe lo] ntihaBtoSseIe:IaBtoSseIeAd agtsl cin@eetrpsNwo [efnvgtoIe stihBrutntmie] sl.aiaintm eRgtaBtoIe:tm; [ue veDdod; spr iwiLa] / D ayadtoa stpatrlaigteve,tpclyfo anb / o n diinl eu fe odn h iw yial rm i. }

Now if you run the app, you should have a bar button item with a + sign that has a custom background. Note that it shows the + button because thats what you get when you choose UIBarButtonSystemItemAdd. Also note that it auto-sizes the button to the correct size automatically because you used a resizable image!

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

25/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

Tapping on the bar button item will push a new View Controller, and you can then see a back button that uses the custom background you created.

Where to Go From Here?


That concludes this tutorial!

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

26/35

1/27/13

Photoshop For Developers: Making a Leather Navigation Bar

To sum up, you used Photoshop to create a custom navigation bar that had buttons with a custom background. You exported the images and then used them in a sample app. This is a big step toward creating custom apps that stand out and look different from the default look and feel of a UIKit app. Congratulations! Here is an example project with the final Photoshop file and sample code for this tutorial. Of course, sometimes you may not want to go through the process of creating Photoshop designs yourself. This is why I created App Design Vault. After all your hard work click here to get a free template that includes custom designs for almost all the UIKit controls including Navigation Bar, Tab Bar, UISwitch, UISegmentedControl, UIButton, UIProgressBar, USlider, iPad and iPhone retina designs, and more.

Please visit the forums to let me know what you think of the tutorial and the free template, and if you have any questions!

This is a blog post by iOS Tutorial Team member Tope Abayomi, an iOS developer and Founder of App Design Vault, your source for iPhone App Design.
Tweet 64

iPhoneCategory: Tags: design, iOS, ios5, iPhone, sample code, tutorial, UIKit I'd love to hear your thoughts! 27 Comments! Add a comment! Ray's Monthly Newsletter Sign up to receive a monthly newsletter with my favorite iOS dev links - receive a free epic-length tutorial as a bonus! Name: Email:
Sign Up!

Sponsors and Friends Advertise Here! Recent Tutorials How To Enable ARC in a Cocos2D 2.X Project Call for Applicants Readers Apps Awards 2012! Readers App Reviews November 2012 How To Use Git Source Control with Xcode in iOS 6 Objectively Speaking: A Crash Course in Objective-C for iOS 6

www.raywenderlich.com/12320/photoshop-for-developers-making-a-leather-navigation-bar

27/35

You might also like