我正在尝试调整图像大小,使其适合导航标题。我给它高度和重量,但看起来仍然很大
这是我的代码:
equal = [(i, j) for i in range (len(l1)) for j in range(len(l2)) if l1[i] == l2[j]]
if equal:
print("Overlapped")
else:
print("Separated")
当我手动将图片编辑为较小尺寸时,它将失去分辨率。 如何使用代码将其设置为58:33?
答案 0 :(得分:0)
我认为您的imageViews大小取决于imageView的intrinsicContentSize
属性。
您可以尝试imageview.invalidateIntrinsicContentSize()
答案 1 :(得分:0)
func addNavBarImage() {
let navController = navigationController!
let image = UIImage(named: "logo-signIn6.png") // Your logo URL here
let imageView = UIImageView(image: image)
let bannerWidth = navController.navigationBar.frame.size.width
let bannerHeight = navController.navigationBar.frame.size.height
let bannerX = bannerWidth / 2 - (image?.size.width)! / 2
let bannerY = bannerHeight / 2 - (image?.size.height)! / 2
imageView.frame = CGRect(x: bannerX, y: bannerY, width: bannerWidth, height: bannerHeight)
imageView.contentMode = .scaleAspectFit
navigationItem.titleView = imageView
}