Is there a way to add a detailed text label and an image in the text bar like this one? I have not been able to find anything that can show me how to do this so I am not sure if there is an easy way to accomplish this. Any help?
答案 0 :(得分:0)
是。创建自定义UIView并将其作为titleView添加到导航栏,如下所示:
let titleView = UIView(frame: CGRectMake(0,0,200,30))
let label1 = UILabel(frame: CGRectMake(0,0,200,15))
label1.text = "Julie"
let label2 = UILabel(frame: CGRectMake(0,15,200,15))
label2.text = "@therealjulie"
titleView.addSubview(label1)
titleView.addSubview(label2)
navigationItem.titleView = titleView
您可以采用相同的方式添加图片。