菜鸟教程小白 发表于 2022-12-11 20:40:05

ios - 更改导航栏标题字体 - 不同


                                            <p><p>如下图所示,我的<code>UIViewController</code>不是<code>UINavigationController</code>,而是普通的<code>UIViewController</code>。我所做的是我使用界面生成器放置了一个 <code>UINavigationBar</code>,并在其上方放置了一个 <code>UIImage</code>。问题是我想改变这个 <code>UINavigationBar</code> 的字体。任何人都知道如何做到这一点?</p>

<p> <img src="/image/JdkVW.jpg" alt="image with the problem"/> </p>

<p>通常,对于一个通用的 <code>UINavigationController</code>,我使用以下代码:</p>

<pre><code>// this will appear as the title in the navigation bar
self.label = [ initWithFrame:CGRectZero];
self.label.backgroundColor = ;
self.label.font = ;
self.label.shadowColor = ;
self.label.textAlignment = UITextAlignmentCenter;
self.label.textColor = ; // change this color
self.label.text = ;
self.navigationItem.titleView = label;
;
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>它应该以同样的方式工作。我认为您只需要 <code>UINavigationBar</code> 的 <code>IBOutlet</code>,或者只需要 <code>UINavigationItem</code> (<code>UINavigationBar</code> 的标题) ) 就是这样。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 更改导航栏标题字体 - 不同,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/8400143/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/8400143/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 更改导航栏标题字体 - 不同