Parallax UITableView header with Auto Layout

I’ve been working on a thing at Shopify, where I implemented a header containing an image that has a parallax effect when scrolling up and expands when scrolling down.

This isn’t exactly a new thing, but I wanted to implement it using Auto Layout and couldn’t find any examples of this. It turns out it’s super simple, so I found some time tonight and created a demo project you can find the code on Github: https://github.com/runmad/ParallaxAutoLayoutDemo

Parallax Auto Layout Demo

To achieve the effect, you simply add the image view inside a container view that gets clipped bounds. Using two NSLayoutContraints, you then set the height of the container view and the height of the image view.

A bit more work is required if you’re working with portrait and landscape images, but the effect is very simple to achieve.

Preventing iTunes Preview glossy app icon

I recently posted a question on Twitter that was left unanswered.

Multiple online searches also left me without a solution, so I decided to test a possible solution with a new update for an app in the App Store and it turns out I found the answer.

The problem I had can be seen with the Facebook app icon on iTunes Preview on the web:

iTunesPreviewBefore

The Facebook app icon on the iTunes Preview on the web shows the app icon with a glossy overlay, a trend that’s pretty much gone with iOS 7 – and I don’t recall the Facebook app icon having a glossy overlay for years either. If you look at the app in the iTunes App Store or on the App Store on your device it does not have a glossy overlay. Furthermore, the rounding of the icon is also different than App Store previews elsewhere (though my glossy-solution won’t solve that issue).

With Xcode 5 I had moved over to using Image Assets which lets you manage all images for app, including icons used in the app for example, as well as app Launch Images and App Icons:

XcodeImageAssets

With Image Assets you can supply various app icon sizes and you do not have to specify them in the app’s .plist and you are also able to specify whether an app icon is pre-rendered (telling Apple not to add a glossy effect for pre-iOS 7 apps). This setting does in fact ensure that you app icon won’t be rendered with a glossy icon on the App Store in iTunes and on devices, but it does not ensure that your app icon won’t have it on iTunes Preview on the web!

In order to get rid of the glossy effect on your app icon, you will have to re-add the UIPrerenderedIcon flag in your app’s .plist and set it to TRUE<. In Xcode this is converted to Icon already includes gloss effects and should be set to YES:

XcodePlistFlag

Once you add this flag to your app’s .plist the app icon in iTunes Preview on the web will new render without a glossy overlay! Tada!

iTunesPreviewAfter

RMSwipeTableViewCell – cell subclass with swipe functionality

RMSwipeTableViewCell is a drop-in UITableViewCell subclass that supports pan gestures as seen in apps such as Clear, Mailbox, Sparrow and many more. It includes a number of delegate callbacks to help you integrate it into any project as well as a number of properties for look and feel customization. Here’s a video where you can see it in action.

RMSwipeTableViewCell Screenshot

RMSwipeTableViewCell was part of an app I am working on but the feature never made it into the final release, so I decided to improve the class and extend it with additional functionality that will allow it to more easily be integrated into other projects.

RMSwipeTableViewCell is available on Github and includes a demo project: https://github.com/runmad/RMSwipeTableViewCell

App Store screenshots and the status bar

Two developers I follow on Twitter have asked pretty much the same question in recent memory: “Should I leave the status bar in iOS App Store screenshots or crop them out?” (link, link).

Crop out the status bar.

I replied to both on Twitter, but thought I’d write up a short post on it. A few people replied to the above tweets saying you should leave the status bar in the screenshots but take out the carrier. Someone even said they’d want to know what colour the status bar is for an app. Not sure customers would decide to buy an app based on the colour the the status bar to be honest.

Here’s what Apple says in the iTunes Connect Developer Guide, taken from the section Before you begin: Creating Assets with the Correct Specifications

The first screenshot you upload in iTunes Connect is used as the main screenshot. It is visible on your app product page on both the desktop App Store and the device App Store. For best results, do not include the iPhone or iPad status bar in your screenshots, and follow the requirements given below. Those dimensions allow you to remove the iOS status bar from screenshots so that you can showcase only the active app area, without distractions.

You can refer to Table 7-3 for screenshot dimensions for the various devices, both with and without the status bar.

But again: Crop out the status bar.

Use of status bar styles

On a related note, I strongly suggest going with a black status bar unless a status bar matching the colour of your navigation bar really enhances the UI.

The Keypad view in the Phone app shows a nice use of the default status bar where the top view seamlessly blends into the status bar. I also find that the status bar looks best when matched with the default navigation bar (blue). Other colours often don’t look right.

You can also mix and match throughout your app. The built in Clock app is a great example of this. The status bar compliments the navigation bar and background on the first two tabs, but the last two views are mainly black, so the status bar is black for these two tabs as well.

Xcode code snippets and syncing

Earlier today I took some time to create a few more code snippets in Xcode for code I’ve been writing a lot of lately. I’ve never really seen or discussed these much with other developers, so I was wondering whether people actually use them – and to what extent? I know from my own experience that I don’t use them nearly enough, so I thought I’d write up a quick post on Xcode’s awesome Code Snippet Library.

The Code Snippet Library in Xcode is a great feature and a huge time saver – you’ll be doing yourself a favour by using it if you haven’t already! Ever noticed how when you start typing “init” Xcode will autosuggest the Objective-C init method? It does this because it’s a code snippet with a completion shortcut “init”. Same with “forin”, “dealloc” and many more built-in code snippets. Check each snippet’s completion shortcut in their edit mode.

Objective-C init method code snippet

Here’s a basic example of a “user” code snippet I have in my library:

UIAlertView boilerplate code snippet

I wrote up the code for a UIAlertView, highlighted the code and dragged it into the Code Snippet Library. The code snippet retains the parameter placeholders as well as your indentation (don’t worry about the indentation in the preview box such as in the example above, as long as it’s correct when used in your code). Now for the awesome part: Notice how I set the Completion Shortcut to “alertview” and the Completion Scope to “Code Expression”? Now, if I type alertview inside a method Xcode will auto-suggest this entire code snippet and I simple hit enter to use it and tab through the parameters to quickly setup a UIAlertView. Thanks Xcode <3

The Completion Scope is fairly important as it allows you to set the scope for when Xcode should auto-suggest your code snippet. If a code snippet is a method, set the scope as such and Xcode won’t auto-suggest that snippet if you’re inside a method. If you’re writing code for both OS X and iOS you can also set a specific platform for the code snippet so you’re not having your UIKit-specific code snippets suggested when you’re writing code for a Mac app.

Keeping your Code Snippet Library in sync

An hour ago, I tweeted about syncing Xcode Code Snippet Library with Xcode, which basically led me to writing up this blog post.

I’ve got my Macbook Pro at work and Mac Pro at home and often switch between the two. Unfortunately Xcode doesn’t have iCloud syncing – though what a nice feature this would be – so keeping your Code Snippet Library in sync could be a small pain. Enter symlinks.

Custom code snippets can be found in

~/Library/Developer/Xcode/UserData/CodeSnippets/

Each code snippet is a plist file, which means adding or deleting code snippets on any machines won’t give you any issues (I believe it would in Xcode 3 because all snippets were saved into one file, which may have created some conflicts depending on the method used to sync).

Assuming you’re a Dropbox user*, you can use it to sync user Code Snippets between two or more machines. In the following example, I’ve setup a folder in Dropbox for Xcode. I’ll move my /CodeSnippet folder to the Xcode folder in Dropbox and setup a symlink in the original path that points to the CodeSnippet folder in my Dropbox:

$ cd ~/Library/Developer/Xcode/UserData
$ mv CodeSnippets /Dropbox/Xcode/
$ ln -s ~/Dropbox/Xcode/CodeSnippets/ CodeSnippets

You may have to sudo the last line, but now you should be all set. Do the same thing on your other machine(s) and start creating lots of useful snippets to use on any machine you’re working on! Don’t forget Completion Shortcuts to make your life much easier.

Hope you found this post useful. If you have similar tips, feel free to share in the comments. @tewha replied to my tweet saying that he uses symlinks to sync Archived builds and other Xcode User Data across several machines.

*If you’re not a Dropbox user, feel free to use my referral link :)

Music from WWDC 2012

Apple is known for its love of music and each year WWDC is filled with a great selection of music played before and after the Keynote, between sessions and during the Beer Bash. It’s a combination of old classics and new tunes, though I find that it’s not exactly Top 20 radio hits (which is a good thing!).

Each year I attend, I collect songs I hear using Shazam or SoundHound. Using SubEthaEdit I share a document and ask that other attendees help fill the playlist. In my experience, there seem to be a playlist of about 50 songs each year that are played throughout the week, some more than others. Since it’s impossible to be in every room, some songs may be missing from the playlist, but hopefully through collaboration, most are there. Feel free to let me know in a comment and I’ll add it to the playlist!

In previous years the band that plays at the Beer Bash gets a number of plays throughout the week, but this year I didn’t hear a single song from Neon Trees. Apple did announce the band early in the week and gave everyone a code to redeem two of the band’s hits through iTunes. While most people didn’t seem to have a clue who they were, I think a lot of people knew them from those two hits. I have included ‘Animal’ and ‘Everybody Talks’ in the playlist below (and on rdio).

Here’s the rdio playlist: http://www.rdio.com/people/runmad/playlists/942543/Music_from_WWDC_2012/

And a .txt version of the SubEthaEdit file: https://dl.dropbox.com/u/5445727/Music from WWDC 2012.txt

Thank you to the following contributors (Name, Twitter, Email):

  • Rune Madsen @runmad rune@theappboutique.com
  • Ola Rönnerup @fnolis ola@ronnerup.se
  • David Wolf @davidwolf david.wolf@gmail.com
  • Grant Burry @grantburry grant@burry.me
  • Scott Andrus @scottandrus scott.andrus@vanderbilt.edu
  • Charles Ying @charlietuna charlesying@gmail.com
  • Mike Park @mikevpark

These were individuals who added their names to the SubEthaEdit document.

I went to one session where they played a track from Best of Bootie 2011 (listed as Titus Jones below). Since it’s a mashup, they may have played more than that one song. It’s a great CD regardless – and free – so worth downloading.

Here’s the playlist, sorted alphabetically (artist – song):

  • Beirut – Santa Fé
  • Beck – Gamma Ray
  • Bob Marley and The Wailers – Exodus
  • Brandon Flowers – Crossfire
  • Cake – Short Skirt/Long Jacket
  • Coldplay – Paradise
  • Coldplay – Talk
  • Edward Sharpe & The Magnetic Zeros – Man On Fire
  • Ellie Goulding – Lights
  • Fatboy Slim – The Rockafeller Skank (Mulder’s Urban Takeover Mix) / 2 PAC + Dr. Dre
  • Florence + The Machine – Shake It Out
  • Foster The People – Helena Beat
  • Foster The People – Houdini
  • Franz Ferdinand – No You Girls
  • Fun. (feat. Janelle Monae) – We Are Young
  • Gorillaz – Dirty Harry
  • Gotye (feat. Kimbra) – Somebody That I Used To Know
  • Here – Man on Fire
  • Imagine Dragons – It’s Time
  • Ini Kamoze – Here Comes the Hotstepper
  • Jack Johnson – From The Clouds
  • Jennifer Lopez feat. Pitbull – On The Floor
  • Julian Casablanca – 11th Dimension
  • K’naan – Wavin’ Flag
  • Kasabian – Fire
  • LCD Soundsystem – Someone Great
  • We Own The Sky – M83
  • Mat Kearney – Ships in the Night
  • Martin Solveig & Dragonette – Hello
  • Michael Franti & Spearhead – Hey Hey Hey
  • Neon Trees – Animal
  • Neon Trees – Everybody Talks
  • No Doubt – Underneath It All
  • OK GO – This Too Shall Pass
  • Owl City – Dreams Don’t Turn to Dust
  • Phoenix – Long Distance Call
  • Ra Ra Riot – Can You Tell
  • Regina Spektor – Don’t Leave Me (Ne Me Quitte Pas)
  • Rooney – When Did Your Heart Go Missing
  • Sara Bareilles – Uncharted
  • Snow Patrol – Take Back the City
  • The Black Keys – Gold On The Ceiling
  • The Black Keys – I Got Mine
  • The Flaming Lips – Yoshimi Battles the Pink Robots Part 1 [Japanese Version]
  • The Hit Crew – I Can See Clearly Now
  • The Killers – Read My Mind
  • The Police – Walking on the Moon
  • The Shins – Simple Song
  • The White Stripes – My Doorbell
  • Train – Drive By
  • Titus Jones – Hello Girl, Let’s Party Til The End (not on rdio, download link above)
  • TV on the Radio – You
  • Two Door Cinema Club – What You Know
  • Tycho – Hours
  • Vampire Weekend – Mansard Roof
  • Vampire Weekend – White Sky
  • Under the Influence of Giants – Mama’s Room

If you’re interested in last year’s playlist, you can find it here.

Enjoy!

Making Rounded Rectangles Look Great (with CSS)

Go directly to the project demo page.

Mike Rundle of flyosity.com recently posted an article, Making Rounded Rectangles Look Great, on designing rounded rectangles, some design techniques, etc. I recommend you to check out the post and download the PSDs for great inspiration!

I’ve recently worked extensively with re-engineering and re-designing the UX and UI for an online retailer, which involved a lot of paper, Photoshop and CSS (or Sass).

I thought it would be cool to create the buttons from Mike Rundle’s article in pure CSS, so I went ahead and did it. Before checking out the CSS buttons, be sure to check out Mike Rundle’s examples and PSDs for a comparison.

I tried as much as possible to stick with the same colours and transparencies as Mike Rundle’s examples, although there may be slight differences, depending your display and browser.

I’ve also added :hover and :active states to all the buttons, so they’re a bit more exciting. Unfortunately CSS doesn’t provide a simple way to create a masked gradient at an angle, so the Convex example is probably the least similar one. But it still looks great and I wanted to stick with all CSS – could have been achieved with an image mask or simple overlay.

You can check out the result on a separate page. Feel free to grab this .zip containing all the project files: Rectangles.zip.

Final #idevblogaday post for this round

This is my last #idevblogaday post for now, and unfortunately I’ve completely run out of time for this week’s post and I can honestly say I don’t have any ideas for it either. How about that!?

Despite it now being a bi-weekly submission, it’s still hard to keep going with new ideas every two weeks :)

But I’d like to thank everyone who’s been reading my previous blog posts and please do check back again in the future. I’ll probably enlist myself in the queue again and try to write some blog posts in the meantime if I come up with some ideas :)

Thanks and sorry for the lack of actual content!

Accessibility on iOS: Working with VoiceOver support

Accessibility on iOS provides visually impaired iOS users the ability to use an awesome touch screen platform to its full extent. It’s your job as an iOS developer to ensure your app works wonderfully with Accessibility on iOS.

When considering adding features or optimizing your app for Accessibility, don’t assume we’re just talking users who are completely blind. And despite being all iOS being full touch screen devices, there are lots of visually impaired users outthere, ranging from users who are blind, hard at seeing or colour blind, for example.

Apps, such as Mail, numerous Twitter clients and more include the possibility of changing text on the screen to a larger font size. Matt RixTrainyard includes an option for players who are colour blind. These are just a few examples of improving apps for Accessibility.

Also consider interaction. While a scroll requires just a flick with one finger for regular use, having VoiceOver enabled scrolling is done with a three finger swipe, and moves the UIScrollView (and any NSObjects that inherit from UIScrollView) a page at a time. So while a pull-to-refresh is awesome, for user with VoiceOver enabled, it might not be as apparent or ease to use.

In this post, I will focus a bit on optimizing your app for VoiceOver. Before continuing with this post, check the video below where a blind user shows off VoiceOver and demonstrates how to use it.

I also recommend enabling VoiceOver on your own device and playing around with it for a while, just to get familiar with it. One thing is to know about it and use it with the Accessibility debugger turned on in Simulator, another thing is to experience it for yourself!

While most of UIKit works fairly well out of the box with VoiceOver, there are plenty of things you can do to improve how your app works with VoiceOver. If you’re doing any custom UI (especially drawing) VoiceOver will most likely not work, or it may speak out the names of the object. So if you call a custom UIButton “createNewTaskButton,” that’s what it will say. Instead, it should probably say “Create New Task”.

Consider your own app(s) and what use visually impaired users may have of it. I made a transit app, so it was only natural to optimize it for visually impaired users and add custom and improved VoiceOver support. With VoiceOver enabled, users can tap the time until the next transit vehicle arrives and the device speaks out in plain English “Next TTC vehicles arrives in 5 minutes and 32 seconds. Tap again to hear updated time.” If I had not customized it, it would have just said “5:32.”

Underneath are subsequent vehicle arrival times. As you can see from the Simulator screenshot, without VoiceOver optimization, the device would just say “20 min bullet 25 min bullet 26 min.” With Voice Over optimization, it says “Subsequent TTC vehicles arrive in 15 minutes (pause) 20 minutes (pause) and 25 minutes. Tap again to hear updated times” Notice the (pause) and look at the screenshot. VoiceOver speaks pretty fast, so if you would like a bit of a pause, just insert a period, and it will pause a bit between the words. This is a great way to split up important information.

Also notice how it will say “and” for the last arrival time. If there are more or less times, it would only say it for the last item. Remember attention to detail in these cases. If someone was to tell you the information for what you touched on the screen, how would you best understand it? There’s a huge different between spoken language and UI. Keep this in mind!

For the buttons with which users can change a route, the label would look like this “506 • Carlton.” In this case, the literal VoiceOver sentence would be “506 bullet Carlton.” So I went ahead and customized this to “506 Carlton,” so it wouldn’t speak the “bullet” part of it. For the custom UIButton where the user can add or delete a route/stop selection to their Favourites, I added “This is a favourite. Double tap to remove from your favourites” and if the selection is not a favourite it would say “Not a favourite. Double tap to add to your favourites.”

If you’re doing any custom drawing, for example as I have done in the example on the right, you will need to pay extra attention to VoiceOver optimizations.

For flat, drawn views, VoiceOver cannot access any of the text or other information on screen. In this example, I draw each cell, so there are no UILabels or UIImageViews for VoiceOver to recognize and speak.

I therefore set the accessibilityLabel property on each cell which then provides VoiceOver with information about what to say. As you can see from the example, according to Accessibility Inspector, VoiceOver will say the route number and name, and because the item is a current selection, I also made sure VoiceOver lets the user know about this by saying “Current selection” after the route number and name.

For non-VoiceOver users, the checkmark is a great visual marker for the item being a current selection. But for VoiceOver users, this would have not been the case. Especially since it’s a custom drawn view, VoiceOver has no clue about the checkmark. In your Accessibility optimization, not only consider what VoiceOver would say, but also consider the UI and what VoiceOver can see, or should see that is related to the item the user it touching.The user may not know about a certain UI object or visual marker without VoiceOver telling them.

Accessibility Inspector in iOS Simulator is a great tool to help optimize your app for full VoiceOver support. Tapping the X button disables the Inspector and hides most of its UI. This enables you to see the app without VoiceOver enabled to quickly get to the content you’re currently debugging for VoiceOver, or since VoiceOver scrolling requires three fingers, it will allow you to scroll when you disable it temporarily.

While Accessibility Inspector shows what VoiceOver will say, you should again test on an actual device with VoiceOver enabled. As mentioned, one thing is how something looks and “sounds” when it’s written, another is how it sounds when VoiceOver speaks it.

So these were a few of the consideration I made for one of my apps in optimizing it for full VoiceOver support. For more on the subject, I urge you to read Apple’s Accessibility Programming Guide for iOS, which gives a more detailed overview of the possibilities as well as more in depth examples and usage guides.

Furthermore, Matt Gemmell has written a great post on it as well with more details on Accessibility properties, among other things, and it’s totally worth checking out.

Core Location presentation at TACOW

Last night, I did a presentation on Core Location for TACOW’s (Toronto Area Cocoa and WebObjects developers group) quarterly meet-up. I volunteered during a lunch with the group’s co-founders David (@rebeld) and Karl (@kolpanic) on the last day of WWDC.

I picked Core Location since I had learned some good insight at WWDC and also worked with the framework thoroughly through building my app Next TTC.

The presentation went well and was well-received, and I am now posting it here for everyone else to enjoy. I have left my notes in the presentation, but I am not sure how much help that will be. I suggest you view the presentation in Play mode, just so the animations help understand the content a bit better.

Download: Core Location Keynote presentation

Enjoy!