Justin Duke

Newfangled Title Text Attributes

In the process of upgrading Xcode 6 to the newest beta I ran headfirst into one of my past sins: glorious and reckless ignorance of the deprecated tag in pursuit of the cheap ecstasy StackOverflow answers.

Specifically, title text attributes. My wanton use of UITextAttributeFont went from yellow nags to blaring red build failures. Ugh.

This is not a particularly exciting or insightful blog post. This is more about me being the dude who spent twenty minutes wandering down the wrong path on Rattlesnake Ledge and, upon finding his way back to the main trail, decided to nail a crude sign 1 to a nearby oak.

Below is a simple table of deprecated title text attributes and their handy-dandy replacements:

attribute old jank new jank
font UITextAttributeFont NSFontAttributeName
text color UITextAttributeTextColor NSForegroundColorAttributeName
text shadow color UITextAttributeTextShadowColor NSShadowAttributeName
shadow offset UITextAttributeTextShadowOffset NSShadowAttributeName

To be more specific with regards to NSShadow, you create an actual NSShadow object and pass it in via NSShadowAttributeName, a la:

var dopestShadowEver = NSShadow()
shadow.shadowColor = UIColor.blackColor()
shadow.shadowOffset = CGSizeMake(width: 0, height: 1)

That’s all I got. I hope the search engine gods whisked you here to some minor level of insight, and that they will carry you to someplace warmer, someplace safer: a place without deprecation.

  1. Crafted with bark, crayons, and the entrails of useless StackOverflow keywords. [return]
Liked this post? You should subscribe to my newsletter and follow me on Twitter.

(I've got an RSS feed, too, if you'd prefer.)