1. 程式人生 > >Learning Xcode 5 As a Designer

Learning Xcode 5 As a Designer

Your First Screen

Let’s create the first screen. In your Storyboard, drag and drop the Image View from Objects Library.
Then, go to Attributes Inspector and change the Image. Xcode will autocomplete if it finds it in your Assets Library.
Try dragging in another Image View and set it to bubble-white. As you resize it, you’ll notice how it nicely stretches.
Next, create the avatar. If you hold Alt, you’ll notice a familiar Sketch feature. ;)
Now drag in a Label to set the text inside. You can set the Lines to 0 so that you can have unlimited lines.
Go to Size Inspector and resize using numbers instead, it’s more precise.
Being the perfertionist that you are, you’ll make it as faithful to the design as possible. :)
For fonts, you will want to select a thinner iOS7-appropriate Helvetica Neue Light.

Type a Message UI

Let’s drag in the View. It’s almost like a folder because you can put anything inside it. It has its own Attributes and is super versatile.
The Text Field has properties that you will be familiar with if you’ve done some CSS. Make sure that the Border style is none.
Then, the infamous Button. Notice the Highlighted state properties.

Navigation Bar

Here’s a neat trick. Go to Help and find “Embed”, then select Embed in Navigation Controller.
In the Left sidebar, select the Navigation Bar. It comes with many styling options preloaded into Storyboard.
Want a title? Edit your View Controller’s Navigation Item’s properties.
Yep, Navigation Bar can have Action buttons. The Object is at the very end of the Library. Make sure to Edit the Tint color since Xcode will take the liberty to tint your images by default.

Rounded Corners

Often in CSS, you don’t want to use images for basic things like rounded corners. Well, in Xcode 5, you can programmatically set the rounded corners. It’s super useful!

For this Table, we’ll create a View that contains everything and add rounded corners. Make sure to Enable “Clip Subviews”. It’s the equivalent of overflow: hidden.
Set the layer.cornerRadius Runtime Attribute with these settings. It’s a hack!
While it won’t show up in Storyboard, you’ll see it when you use the Simulator.

Linking To Another Screen

Create an Empty button and place it in your View.
From that button, hold Ctrl and drag it to the other screen. Choose Push. Make sure that on the root screen, you have a Navigation Bar, or it won’t work.

1px Lines

Xcode works in pt units. You can’t really create a View and set it to 0.5pt or 1px. So in order to create that hair line, you have to manually create a one pixel asset.

Toolbar Navigation

iOS’s stock toolbar is pretty customizable, allowing you to change the colors, texts and icons.

With your View Controller selected, search Embed again, but this time select Tab Bar.
Just like the Navigation Bar, you have options for each View Controller.
Sometimes, you don’t want the Navigation Bar or the Toolbar, so you must hide them by Selecting Bottom Bar to None and check “Hide Bottom Bar on Push”.

Scrolling

Everyone loves that Bounce back scroll that iOS has. But in order to achieve that, you must have a Table View as a container. The structure is: Table View / View (full) / Your objects.
Careful, Table Views and Views come preloaded with a White background. Make sure to set to Clear color.
It can be interesting to have a Scrolling area in parts of the screen.

Download the Xcode Project

Go ahead, play with the Ripple Xcode functional prototype and edit the styling as you wish: http://cl.ly/2A0m0j0i0g1K

No Codes

If you look past the complex parts, Xcode is way friendly than HTML/CSS/SCSS/Javascript. It has a powerful UI that allows you to edit most of the visual elements of your App. In a way, it’s what WYSIWYG should have been. Next time, I will discuss the use of third-party Libraries using CocoaPods and enabling custom Fonts, sounds and animations with as little coding as possible. If you’d like to follow the development of these Xcode tutorials or Ripple, feel free to follow me: @mengto on Twitter. :)