Search code examples
iosswiftstoryboarduilabel

Storyboard: centre text horizontally in UILabel


I know how to do it programmatically:

textLabel.textAlignment = .center

But isn't it possible to do that in storyboard? Unbelievable.
There is an appropriate property called "Content Mode: Center" in the attributes inspector, but seems it doesn't work.


Solution

  • As @Sweeper has said in the comments. The UILabel has an Alignment property which you can find under the Attributes Inspector tab, set the value to Center represented by horizontally centred dashes.

    Text alignment