Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UINavigationBar详细信息文本标签_Ios_Swift_Uikit_Uinavigationbar - Fatal编程技术网

Ios UINavigationBar详细信息文本标签

Ios UINavigationBar详细信息文本标签,ios,swift,uikit,uinavigationbar,Ios,Swift,Uikit,Uinavigationbar,有没有办法像这样在文本栏中添加详细的文本标签和图像?我还没有找到任何东西可以告诉我如何做到这一点,所以我不确定是否有一个简单的方法来完成这一点。有什么帮助吗 是的。创建自定义UIView并将其作为标题视图添加到导航栏,如下所示: let titleView = UIView(frame: CGRectMake(0,0,200,30)) let label1 = UILabel(frame: CGRectMake(0,0,200,15)) label1.text = "Julie" let la

有没有办法像这样在文本栏中添加详细的文本标签和图像?我还没有找到任何东西可以告诉我如何做到这一点,所以我不确定是否有一个简单的方法来完成这一点。有什么帮助吗


是的。创建自定义UIView并将其作为标题视图添加到导航栏,如下所示:

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
您可以用同样的方法添加图像