导航栏中的按钮图像正在拉伸

时间:2017-06-23 20:21:13

标签: ios swift uinavigationbar

我正在尝试将图像添加到左侧栏中,但即使rect是30x30,图像也会被拉伸。知道为什么会发生这种情况或如何解决它? enter image description here

button.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
button.layer.cornerRadius = button.bounds.size.height / 2
button.clipsToBounds = true
button.imageView?.contentMode = .scaleAspectFill
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: button)

1 个答案:

答案 0 :(得分:0)

这个问题有没有解决?我一旦更新到swift 4就没有遇到过这个问题我遇到了这个问题并找不到解决方法。