iphone - 右对齐 self.navigationItem setTitleView
<p><p>我需要将 navigationItem TitleView 对齐到最右边。 (navigationItem rightBarButtonItem 通常出现的地方)</p>
<p>如何做到这一点?</p>
<p>我已经尝试过了,但没有运气,它仍然将 TitleView 放在中心:</p>
<pre><code>CGRect titleViewPos = CGRectMake(300, 0, 200, 10);
self.navigationItem.titleView.frame = titleViewPos;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>UILabel *lbl = [initWithFrame:CGRectMake(0, 0, 320, 44)];
lbl.textAlignment = UITextAlignmentRight;
lbl.backgroundColor = ;
lbl.text = @"TITLEVIEW";
self.navigationItem.titleView = lbl;
</code></pre>
<p>你会得到输出</p>
<p> <img src="/image/ZWkK0.png" alt="enter image description here"/> </p></p>
<p style="font-size: 20px;">关于iphone - 右对齐 self.navigationItem setTitleView,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/16296828/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/16296828/
</a>
</p>
页:
[1]