UI按钮的图像在iOS中被拉伸

时间:2016-04-03 00:30:57

标签: ios iphone xcode swift

我在导航栏中添加了一个右侧栏按钮,然后将图像分配给UIButton并将大小设置为20px * 20px

编辑器中的视图很好,但是当我在模拟器中运行应用程序时,图像非常紧张,任何人都可以帮助我

图像在这里

enter image description here

2 个答案:

答案 0 :(得分:0)

UIButton中,设置button.image.contentMode = UIViewContentModeScaleAspectFit

答案 1 :(得分:0)

控制单击并从按钮拖动到视图控制器作为IBOutlet

override func viewDidLoad(){
yourButtonOutletName.image.contentMode = .ScaleAspectFit

//        
}
相关问题