问题描述
所以我想在导航控制器导航栏的标题下添加一个副标题".
到目前为止,我查找的大部分内容都希望我使用 CGRect.我不太清楚那是什么,听起来它想让我创建一个全新的视图,这不是我想做的.
我的问题是,有没有一种点法可以轻松添加字幕视图?
我发现的最接近的东西是在堆栈溢出上发布的,这是链接:
来源:https://gist.github.com/nazywamsiepawel/0166e8a71d74e96c7898
So I'm wanting to add a "subtitle" under the title in the navigation bar in navigation controller.
Mostly everything I look up so far wants me to use CGRect. I don't know a whole lot what that is and it sounds like its wanting me to create an entire new view which is not what I am wanting to do.
My question is, is there a dot method to adding a subtitle view easily?
The closest thing I found was posted on stack overflow and here is the link:
Create a subtitle in navigationbar
Apparently last year this worked but now I am getting errors and it's in my viewDidLoad...
I tried this:
self.navigationController?.navigationItem.prompt = "Subtitle Here"
It's the only thing that won't show any errors but still doesn't work. It literally does nothing. At least nothing visible at run time.
On a side note, swift is preferred. Thanks!
Though there is a solution but it has some known issues
Solution is writing a function like this
Using this function for custom navigation title view in viewDidLoad
Only known issue is that if subtitle becomes very large than the misplacement occurs.
Final Outcome
Source: https://gist.github.com/nazywamsiepawel/0166e8a71d74e96c7898
这篇关于在Xcode导航栏控制器的标题下添加字幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!