Create navigation bar with title and subtitle
func setsubTitle(titleStr: String, subStr: String,viewControl:UIViewController) {
let rect = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 50)
let titleSize: CGFloat = 20
let subtitleSize: CGFloat = 15
let titleLabel = UILabel(frame: rect)
titleLabel.backgroundColor = .clear
titleLabel.numberOfLines = 2
titleLabel.textColor = .white
let text = NSMutableAttributedString()
text.append(NSAttributedString(string: titleStr, attributes: [.font : UIFont.boldSystemFont(ofSize: titleSize)]))
text.append(NSAttributedString(string: "\n\(subStr)", attributes: [.font : UIFont.systemFont(ofSize: subtitleSize)]))
titleLabel.attributedText = text
viewControl.navigationItem.titleView = titleLabel
}
Comments
Post a Comment