person101 person101 - 11 months ago 59
Swift Question

How to make a UILabel upside down in XCode, using Swift?

I would like to have a label that is displayed upside down, when the view did load.

Here is the default code given in the ViewController.swift, and I had also added the UILabel as an outlet.

import UIKit

class ViewController: UIViewController {

@IBOutlet var Label: UILabel!

override func viewDidLoad() {


override func didReceiveMemoryWarning() {



Also sorry if this is a dumb question I am very new to IOS development and swift.


To rotate your label in viewDidLoad just use the following :


override func viewDidLoad() {
    var aLabel: UILabel = ...
    aLabel.transform = CGAffineTransformMakeRotation(M_PI)

Objective C

-(void) viewDidLoad {
    [super viewDidLoad];

    UILabel *aLabel = ...
    aLabel.transform = CGAffineTransformMakeRotation(M_PI);

M_PI will make a rotation of 180 degrees which will result in an upside down label.