如何在Swift3中增加UIButton图像大小?

时间:2017-07-11 06:29:41

标签: ios swift3 uibutton xcode8

我使用UIImage的默认UIButton属性来设置背面图像。我已经成功完成了它,但似乎image看起来很小。如何在UIButton

中增加图片的大小
    let viewForNavigation = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 40))
    viewForNavigation.backgroundColor = UIColor.clear
    let backbutton = UIButton(frame: CGRect(x: 0, y: 8, width: 320, height: 20))
    backbutton.setImage(UIImage(named: "back_button"), for: UIControlState.normal)
    backbutton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right:10)
    backbutton.contentHorizontalAlignment = .left
    backbutton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)
    backbutton.titleLabel!.font = UIFont().robotoMedium(withFontSize: 20)
    backbutton.setTitle(title, for: .normal)

    backbutton.setTitleColor(UIColor.black, for: UIControlState.normal)
    backbutton.addTarget(self, action: #selector(exitViewController), for: UIControlEvents.touchUpInside)
    viewForNavigation.addSubview(backbutton)
    let rightBarButton = UIBarButtonItem(customView: viewForNavigation)
    self.navigationItem.leftBarButtonItem = rightBarButton

Please see the image. I need to increase the image size

1 个答案:

答案 0 :(得分:0)

我认为您选择了错误尺寸的后退按钮图像,请使用下面的图像作为后退按钮:

enter image description here

enter image description here

enter image description here

<强>输出

enter image description here