[英]How to set navigationItem.titleView image horizontal center?
您好,我在UIImageView
徽標中使用UINavigationBar
在im內有一個簡單項目,但是某些徽標的徽標看起來30-40px
右側30-40px
或某些徽標在左側50-60px
?
如何設置navigationItem.titleView圖像水平居中?
我的代碼在下面。
navigationController!.navigationBar.barTintColor = UIColor.clearColor()
navigationController!.navigationBar.tintColor = UIColor.whiteColor();
let imageView = UIImageView(frame: CGRect(x: 50, y: 0, width: 164, height: 38))
imageView.contentMode = .ScaleAspectFit
let image = UIImage(named: "logo.png")
imageView.image = image
navigationItem.titleView = imageView
輸出圖片;
另外,當我將x:50
更改為x:80
或x:0
等時,什么也沒發生!
您可以將x原點設置為0
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 164, height: 38))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.