【发布时间】:2016-10-19 19:43:42
【问题描述】:
我正在尝试在导航栏中使用图像。继续靠近,但没有雪茄。使用下面的代码,它可以很好地加载图像并将其定位几乎正确。它似乎在视图周围有一个垫子,但我对它没有任何限制。当我删除状态栏时,它会缩小图像,但将其定位在导航栏中。
let nav = self.navigationController?.navigationBar
for parent in self.navigationController!.navigationBar.subviews {
for childView in parent.subviews {
if(childView is UIImageView) {
childView.removeFromSuperview()
}
}
}
nav?.barStyle = UIBarStyle.Default
nav?.tintColor = UIColor.blueColor()
let app = UIApplication.sharedApplication()
let SBheight = app.statusBarFrame.size.height
let totalheight = SBheight + nav!.frame.height
let totalwidth = nav!.frame.width
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: totalwidth , height: totalheight))
imageView.clipsToBounds = true
imageView.contentMode = .ScaleAspectFill
var image = UIImage(named: "HRC")
imageView.image = image
navigationItem.titleView = imageView
这是导航栏区域的截图:
【问题讨论】:
标签: ios swift uiimageview navigation frame