How to force UILabel to draw a text with upper case chars?

You were asking if there might be an equivalent to the CSS declaration text-transform: uppercase; for attributed text in iOS. Unfortunately this is not available, and I agree that it could be convenient to add an attribute for this.

I've personally subclassed UILabel, added an uppercase boolean property, and overridden the text setter so that it will automatically call uppercaseString on the new value if uppercase is set to true.


This is the Swift 3 & Swift 4 version:

titleLabel.text = titleLabel.text?.uppercased()

Objective-C

NSString *text = @"Hello";
[myLabel setText:[text uppercaseString]];

Swift 3 & 4

let text = "Hello"
myLabel.text = text.uppercased()