iOS:隐藏后退按钮时如何使导航标题左对齐
<p><p>我已经按照这段代码在导航栏中实现了标题和副标题:<a href="https://stackoverflow.com/questions/2817181/iphone-title-and-subtitle-in-navigation-bar" rel="noreferrer noopener nofollow">iPhone Title and Subtitle in Navigation Bar</a>
效果很好。但是,我有一个部分通过以下方式隐藏了后退按钮:</p>
<pre><code>self.navigationItem.hidesBackButton = YES;
</code></pre>
<p>我希望标题占据左侧按钮所在位置的额外空间。</p>
<p>这可能吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>设置navigationItem.titleView的原点</p>
<p>例如</p>
<pre><code>- (void)viewWillAppear:(BOOL)animated
{
;
if (self.navigationItem.hidesBackButton) {
CGRect frame = self.navigationItem.titleView.frame;
frame.origin.x = 10;
self.navigationItem.titleView.frame = frame;
}
}
</code></pre></p>
<p style="font-size: 20px;">关于iOS:隐藏后退按钮时如何使导航标题左对齐,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/6695799/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/6695799/
</a>
</p>
页:
[1]