Skip to content

Instantly share code, notes, and snippets.

@joninsky
Created October 18, 2018 04:07
Show Gist options
  • Save joninsky/388cc03e54b01a069b91399108573de6 to your computer and use it in GitHub Desktop.
Save joninsky/388cc03e54b01a069b91399108573de6 to your computer and use it in GitHub Desktop.
Shows basic use of Icon Font on a UILabel. Also demonstrates basic constraints in code.
import UIKit
class RootViewController: UIViewController {
//MARK: Properties
let label = UILabel(frame: .zero)
//MARK: Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
//Set up label
self.label.translatesAutoresizingMaskIntoConstraints = false
self.label.textAlignment = .center
self.label.font = IconFont().iconFont(50)
self.label.text = IconFont().arrow_right
self.label.textColor = UIColor.red
//Set up view
self.view.addSubview(self.label)
self.view.backgroundColor = UIColor.white
self.label.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 0).isActive = true
self.label.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 0).isActive = true
self.label.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0).isActive = true
self.label.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 0).isActive = true
}
//MARK: Functions
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment