Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning iOS UI Development
Learning iOS UI Development

Learning iOS UI Development: Implement complex iOS user interfaces with ease using Swift

eBook
€13.98 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Learning iOS UI Development

Chapter 2. UI Components Overview – UIKit

As with many other operative systems, iOS comes with its own UI library, UIKit, which is much more than a simple list of UI components. After reading the rest of this book, you'll realize that many topics are strictly connected to it—think of gestures, for instance. This chapter will be a basic overview of the main UI components provided by the framework; you'll learn how to use a component by adopting the most common properties and which functionalities you can work with while developing a user interface.

This chapter covers many different but related topics. Here is an overview of what you will read about in the next pages:

  • Text elements and the keyboard
  • Buttons, selectors, and user interaction
  • View-based components
  • A UI for structured data
  • Custom components with the UIAppearance protocol

Exploring text elements

There are different ways to display text in iOS. You can draw strings directly in a graphic context through NSString or NSAttributedString or take advantage of the power of Text Kit, a framework dedicated to text drawing that is involved in all the controls we'll see in the next paragraphs. UIKit provides some really helpful classes built on Text Kit, which will simplify your work, allowing you not to worry about the way text is drawn. Let's go through all these classes.

Presenting text with UILabel

UILabel is a class that simply draws strings. Its text and attributedText properties define the text that is displayed by the label; the former receives a simple NSString instance to display plain text, while the latter receives an NSAttributedString instance to include styles, such as bold and italic, or draw strings with different colors and fonts:

Presenting text with UILabel

The aspect of a label can be changed using dedicated properties:

  • textColor: This is used for plain strings. It...

Exploring buttons and selectors

UIKit provides a great list of components that you can include in your user interfaces to intercept user input. Most of the UI elements you will see in this section are based on the UIControl class, and their main role is to convert touch events into actions or choices. How the user interacts with a control depends on the type of the control itself.

There are simple buttons that can be tapped to trigger an action, for instance, or controls that accept drag and drop—think sliders or switches—to set a value. Don't worry if you don't find the control that fits your needs. Later in this book (Chapter 8, How to Build Custom Controls, specifically), you will learn how to implement a completely custom control. You'll notice that just as for the default controls, the starting point will be the UIControl class.

UIButton and user interaction

The UIButton class defines generic buttons that intercept the user's tap. You can create different...

View-based components

The following controls are subclasses of UIView, and they are useful to display noninteractive information or act as containers.

Showing progress with UIProgressView

A progress view is an indicator of progress over time. You can see an example of this control during downloads or when sending an e-mail from the Mail app:

Showing progress with UIProgressView

This control is extremely simple. The only property you need to set and read is progress, a value between 0.0 and 1.0. When this value is 0.0, the progress bar is empty, while it is full when its value is equal to 1.0. You can perform a simple animation if you set the progress value using the setProgress:animated: function and passing true for the animated parameter.

Control customization

The control can be easily customized with dedicated functions. You can customize the track that is not filled by specifying a tint with the trackTintColor: function or even using an image with the trackImage: function. The same customizations are available for the progress...

Managing and presenting structured data

When there's a lot of information to be shown in a single view, you can rely on specific controls that are optimized for this very task: the table and collection views.

Introducing UITableView

A table view displays a list of cells through a vertical scrollable layout. All the items presented by a table view can be grouped in sections, and some supplementary information, such as headers and footer, can be attached to the UI to improve the readability of the information.

UITableView is a subclass of UIScrollView and inherits all the functionalities from this class.

Introducing UITableView

The cells presented by a table are instances of UITableViewCell (or its subclasses). You can use some prebuilt cell types that are provided by the system (basic, right detail, left detail, and subtitle) and end up being very useful if you just want to display simple information. Alternatively, you can build your own cell styles so that they can accommodate any type of information your data...

The UIAppearance protocol

If there's one thing the controls we've talked about so far have in common, it is that they can be graphically customized with the use of simple functions. This is a great a feature that has been added to UIKit since iOS5, and it allows us to modify the looks of any default control with just a few lines of code.

This feature is improved by the UIAppearance protocol that, thanks to the appearance proxy, forwards the customizations to all the instances of a specific class. The appearance proxy for a class can be retrieved using the appearance function, and as it returns instancetype, its properties can be easily accessed. Here is an example of the code needed to set onTintColor for all the UISwitch instances of an application:

UISwitch.appearance().onTintColor = UIColor.redColor()

The properties that take part in the UIAppearance protocol and can therefore be modified through the appearance proxy must be marked with the UI_APPEARANCE_SELECTOR tag. This portion...

Exploring text elements


There are different ways to display text in iOS. You can draw strings directly in a graphic context through NSString or NSAttributedString or take advantage of the power of Text Kit, a framework dedicated to text drawing that is involved in all the controls we'll see in the next paragraphs. UIKit provides some really helpful classes built on Text Kit, which will simplify your work, allowing you not to worry about the way text is drawn. Let's go through all these classes.

Presenting text with UILabel

UILabel is a class that simply draws strings. Its text and attributedText properties define the text that is displayed by the label; the former receives a simple NSString instance to display plain text, while the latter receives an NSAttributedString instance to include styles, such as bold and italic, or draw strings with different colors and fonts:

The aspect of a label can be changed using dedicated properties:

  • textColor: This is used for plain strings. It defines the...

Left arrow icon Right arrow icon

Key benefits

  • Build compelling user interfaces that users will enjoy using the iOS UIKit framework
  • Make your iOS apps easily recognizable and familiar with the UIKit framework
  • Use this comprehensive, step-by-step guide to create a complete custom layout

Description

Through this comprehensive one-stop guide, you’ll get to grips with the entire UIKit framework and in a flash, you’ll be creating modern user interfaces for your iOS devices using Swift. Starting with an overview of the iOS drawing system and the available tools, you will then learn how to use these technologies to create adaptable layouts and custom elements for your applications. Next, you’ll be introduced to other topics such as animation and code-drawing with Core Graphics, which will give you all the knowledge you need to create astonishing user interfaces. By the end of this book, you will have a solid foundation in iOS user interface development and will have gained valuable insights on the process of building firm and complex UIs.

Who is this book for?

This easy-to-follow guide is perfect for beginner-level iOS developers who want to become proficient in user interface development. It would also be useful for experienced iOS developers who need a complete overview of this broad topic all in one place, without having to consult various sources.

What you will learn

  • Understand the basic requirements to work with iOS user interfaces
  • Get to know about the UI tools, frameworks, and built-in components
  • Plot dynamic layout structures using Auto Layout
  • Shape and implement adaptive user interfaces for different screen sizes
  • Draw and animate your user interfaces using the CALayer and UIKit animations
  • Intercept and handle user touches to create user interface interactivity
  • Create and depict totally custom controls
  • Design with iOS through Core Graphics

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 30, 2015
Length: 196 pages
Edition : 1st
Language : English
ISBN-13 : 9781785288197
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Dec 30, 2015
Length: 196 pages
Edition : 1st
Language : English
ISBN-13 : 9781785288197
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 94.97
Test-Driven iOS Development with Swift
€32.99
Swift 2 Blueprints
€36.99
Learning iOS UI Development
€24.99
Total 94.97 Stars icon

Table of Contents

10 Chapters
1. UI Fundamentals Chevron down icon Chevron up icon
2. UI Components Overview – UIKit Chevron down icon Chevron up icon
3. Interface Builder, XIB, and Storyboard Chevron down icon Chevron up icon
4. Auto Layout Chevron down icon Chevron up icon
5. Adaptive User Interfaces Chevron down icon Chevron up icon
6. Layers and Core Animation Chevron down icon Chevron up icon
7. UI Interactions – Touches and Gestures Chevron down icon Chevron up icon
8. How to Build Custom Controls Chevron down icon Chevron up icon
9. Introduction to Core Graphics Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(5 Ratings)
5 star 60%
4 star 20%
3 star 0%
2 star 20%
1 star 0%
Andras Pasztirak Feb 16, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is the first iOS programming book I really enjoyed reading. Being an Android and Web developer the iOS concepts never really clicked in my head when I was reading articles or when I was watching the Stanford lectures. I always stumbled my way through whenever an iOS job came up.After having read this book things really fell in place in my mind, I now have a decent idea what I'm doing on iOS. It's a very nicely struck balance of basic explanations, thorough instructions and very good code samples to go with it all. The book is well structured and easy to follow along but it's just as easy to pick out specific areas you wish to study and jump right into the middle of it. I'd very much recommend it to anyone who is just starting out on iOS and wants to understand not only how the UI framework works but also learn about the more basic concepts of iOS development. 5/5
Amazon Verified review Amazon
pauland Feb 01, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Let's say at the outset that I really like this book. I read a lot of computer books and it's often the case that the books cover the subject but getting at what you want requires working through examples (do this, do that .. ) in a series of exercises. This isn't a book like that - thank goodness.The book guides you through the interface concepts of IOS and explains them in a very clear and concise way. If you read through the book you should have a really good understanding about how UIs are built in IOS. The explanations are very clear and it's nice to see examples that show you how to reskin a slider or build your own UI component of your own.The book covers 'conventional' UI building but doesn't cover the frameworks used for building many games spritekit(2D) and scenekit (3D).The book is described as being suitable for beginner and experienced developers and I would agree with that. If you are very new to iPhone development, don't make this the first book that you read. Make something with the tutorial style books, then when you want to properly understand how things work without doing a ton of follow-me tutorials, buy this book.My favourite computer book BY FAR in recent times. I really hope the author writes more.
Amazon Verified review Amazon
Chris Everett Mar 31, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is a wonderful read. I absolutely loved it. The book is described as being suitable for beginner and experienced developers and I would agree with that. The book guides you through the interface concepts of IOS and explains them in a very crisp and precise manner. I would certainly recommend this book.
Amazon Verified review Amazon
abigail Feb 01, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I like this book because explain the code for design layout and autolayout with code for practice and the conplete code for the samples of the book. I like that the books has examples and code. It's simple and explain some tips for the interface builder. I think that is a good book for help to know about the layout in ios
Amazon Verified review Amazon
Amazon Customer Dec 03, 2016
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Pretty much useless book. It scratches just a surface of the such huge topic as iOS UI. Especially taking into account incredible high price.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.