Finally, Hue can analyze a UIImage, returning a tuple of colors it finds inside.
let(bg,primary,secondary,_)=albumArt.colors()
It provides background, primary, secondary and detail colors from the image. We can the use these to create interfaces such as the one found in iTunes on OS X, where the colors in the UI match those found in the album artwork. Neat!
Today we'll follow up with another Bite in our localization series (sort of). Units of measurement are important to get right when localizing our apps for different cultures.
Today we'll look at a library from Khoa Pham called Scale that can help us convert between different units of measurement (for either localization or just-for-fun purposes). Let's begin.
Scale makes it incredible simple to work with different units of measurement:
In iOS 9, the Contacts framework replaced AddressBook.framework as the suggested way to interact with that data. Today we'll check out a library called EPContactsPicker, which is built on top of the Contacts framework and encapsulates a lot of the boilerplate logic. Let's dive in.
Localization can go a long way towards increasing the sales of our apps. Users are browsing the App Store all over the world, and when they come across a neat looking app that's not translated into their language, they're very likely to keep on scrolling. Today weโll check out a library called Localize-Swift from Roy Marmelstein that makes this process much nicer.
The first helpful addition Localize-Swift brings us is a better way to localize our strings:
searchBar.placeholder="Hello World".localized()
Then we can easily test our translations at runtime using:
Localize-Swift also provides a custom genstrings.py script to easily fill our .strings files even though we're not using NSLocalizedString directly, neat!
When a user first installs one of our apps, it'd be nice if we could hold their hand a bit, pointing out where the important bits are.
Today we'll look at Gecco, a library that can make creating these walkthroughs quite easy. Let's dive in.
Gecco is built using UIKit's custom transition protocols.
This means there's simply a view controller that we'll configure and present over our content that will display the "spotlight" effect.
In it's most basic form, we can use Gecco by creating a SpotlightViewController, then configuring it's spotlight property to be one of the supplied Oval, Rect, or RoundRectenum cases:
Then we simply present it like normal, neat! In simple cases this is all we need, next we'll look at customizing things further.
We can actually subclass Gecco'sSpotlightViewController and use it's spotlightViewproperty to animate the spotlight effect calling out different shapes, even morphing from one to another:
Note about hard-coding values: We've used exact values here to make it easy to understand how Gecco works. In a real world scenario, you would probably be grabbing these values from your views after they've been through a layout pass.
More info about Gecco can be found at git.io/gecco
iOS has some great built-in support for different keyboards for different types of data, but the built-in numeric-keypadkeyboard style does leave a few things to be desired (a "done" button, decimal point, a "hide" button, etc).
Today we'll look at a library called MMNumberKeyboard by Matรญas Martรญnez that does a great job of filling in these gaps. Let's try it out.
Setting up a text field to use the library's keyboard is extremely straightforward. First we'll create and configure the keyboard:
Breakpoints in Xcode are a great way to pause execution and poke around at what's going on in our app. Today we'll look at some ways we can use them without pausing execution. Let's dive in.
We'll start by pressing (while editing) to set a breakpoint:
Then, we can right click to edit the breakpoint. The popover that appears may appear simple, but it's packing tons of power.
We'll enable that last checkbox straight away, then click Add Action to see our available options.
We can add a Debugger Commandaction to (for example) print a value whenever the breakpoint hits. We now have a dynamic log statement we can easily enable/disable.
The last option, "Sound", might not seem that useful at first glance. We can use this to (for example) debug high performance code, or whenever we'd like to hear an audible "ding" when a certain code path is hit.
After adding an action, we'll see a couple +/- buttons, this means we can actually pair both these techniques together, neat. Happy debugging!
It can help us add loading, empty, and error states to our view controllers. Let's get started:
Most apps we build must load data before showing it to the user. Those apps will also need to handle the case where there's no data available, or when something goes wrong.
StatefulViewController allows us to easily add all of this functionality to our view controllers.
While this might seem trivial, there's actually quite a bit of logic and state management involved. StatefulViewController helps eliminate boilerplate and help us focus on building the parts of our app that make it unique and useful.
Let's try it out. First, we'll make a view controller, and adopt the protocol:
Parallax headers have become very common in iOS apps. They're a great way to (for example) show off large graphical content, or summarize/focus a screenful of content.
A parallax header essentially involves displaying a view above a scroll view, which grows and shrinks as the user scrolls the scroll view.
It's also common to see the content of the parallax header view re-center itself as the user scrolls, so the content is visible for as long as possible while scrolling up.
MXParallaxHeader offers a few different options that make customizing this behavior quite simple.
We can center, fill, or lock our content to the top or bottom. Neat!
Let's use MXParallaxHeader to add a simple parallax header to a scroll view:
Even cooler than that, MXParallaxHeader extends UIViewController to add a couple extra properties that allow us to easily add parallax header to any view controller.
Header views can optionally adopt the MXParallaxHeaderProtocol to implement custom parallax animations based on the user's scroll progress: