Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension UINavigationItem {
- func setTitle(title:String, subtitle:String) {
- let one = UILabel()
- one.text = title
- one.font = UIFont.systemFont(ofSize: 17)
- one.sizeToFit()
- let two = UILabel()
- two.text = subtitle
- two.font = UIFont.systemFont(ofSize: 12)
- two.textAlignment = .center
- two.sizeToFit()
- let stackView = UIStackView(arrangedSubviews: [one, two])
- stackView.distribution = .equalCentering
- stackView.axis = .vertical
- let width = max(one.frame.size.width, two.frame.size.width)
- stackView.frame = CGRect(x: 0, y: 0, width: width, height: 35)
- one.sizeToFit()
- two.sizeToFit()
- self.titleView = stackView
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement