Created
October 18, 2018 04:07
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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