2017-07-11 1 views
0

Ich verwende die Standard UIImage Eigenschaft des UIButton, um das hintere Bild festzulegen. Ich habe es erfolgreich gemacht, aber es scheint, dass die image erscheint klein. Wie vergrößert man das Bild in UIButton?Wie kann man die Bildgröße von UIButton in Swift3 erhöhen?

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

statt setImage können Sie setBackground Bild verwenden. –

Antwort

0

Ich glaube, du falsche Größe Schaltfläche Bild wählen zurück haben, bitte zurück Button Bild verwenden:

enter image description here

enter image description here

enter image description here

Ausgabe

enter image description here

+0

Danke :) @Chelsea Shawra –

Verwandte Themen