Category: Swift Swift
-
Using Attributed Strings in Swift 3.0
For most uses, a basic string works well. Normal strings have no character or paragraph formatting. They rely on the properties of the control to format them. The system only formats the full string, not parts of it. For formatting a part of a string, you need an attributed string which specifies parts of the…
-
How to Use Custom Table Cells in a UITableView
While very versatile, there’s some point where every developer finds table views lacking something: the cell format is too limited. Apps like Facebook, Twitter, and Instagram don’t use simple table views. They use custom table cell formats. In this lesson, we’ll start learning how to make and use custom table view cells. Set Up the…
-
Using Trait Collections for Auto Layout and Size Classes
Suppose you have a project with adaptive layout, but you hate storyboards. You’ve coded all your layout and then find something horrible: it only codes well in portrait on an iPhone. You’ve decided that some of the elements need to be in a different place in portrait and completely different places on an iPad. In…
-
Auto Layout for XCode 7
I’m pleased to announce that my latest book Practical Auto Layout for Xcode 7 is now available in both Amazon Kindle and iBooks formats. This is an update to my earlier book Practical Auto Layout, with more material to include coverage of the iPad multitasking panes and stack views. Once you understand stack views, your…
-
How to Add Stack Views Programmatically and (almost) avoid AutoLayout
Some people don’t like Interface Builder and like to code instead. Sometimes your layout is so dynamic you need to lay out in code. In either case, programmatic layout of views becomes the answer instead of auto layout. In Xcode 7 Apple introduced stack views. In an earlier post, I introduced stack views in Interface…