[英]How to set navigationItem.titleView image horizontal center?
Hello I have simple project inside im using UINavigationBar
inside UIImageView
logo but some views my logo looking 30-40px
right side or some views looking 50-60px
left side ? 您好,我在
UIImageView
徽标中使用UINavigationBar
在im内有一个简单项目,但是某些徽标的徽标看起来30-40px
右侧30-40px
或某些徽标在左侧50-60px
?
How to set navigationItem.titleView image horizontal center ? 如何设置navigationItem.titleView图像水平居中?
My codes under below. 我的代码在下面。
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
Output picture ; 输出图片;
Also when i change x:50
to x:80
or x:0
etc.. nothing happend ! 另外,当我将
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.