2017-07-11 6 views
0

UIButtonのデフォルトのUIImageプロパティを使用して、バックイメージを設定しています。私は正常にそれをやったが、それはimageが小さく見えているようだ。 UIButtonで画像のサイズを大きくするにはどうすればいいですか?Swift3で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

+0

代わりのsetImageあなたはsetBackground画像を使用することができます。 –

答えて

0

私はあなたがボタン画像を間違ったサイズをバック選択があると思う、バックボタンの画像の下に使用してください:

enter image description here

enter image description here

enter image description here

出力

enter image description here

+0

ありがとう:) @Chelsea Shawra –

関連する問題