title: How to change the height and width of a button in iOS app using Swift 4.0 which is developed using Swift 3.0
body: <p>I am completely new to iOS development and I am supposed to fix some bugs in an iOS app which is made using Swift 3.0 and Xcode 8 and it works almost fine. But when I open it with Xcode 9 and Swift 4.0 it shows some buttons way different that they were before. </p>
  
  <p>Here is the source code for one of those buttons.</p>
  
  <pre><code>let button: UIButton = UIButton.init(type: UIButtonType.custom)
      //set image for button
      button.setImage(UIImage(named: "menu.png"), for: UIControlState())
      button.frame = CGRect(x: 0, y: 0, width: 30, height: 23)
      let barButton = UIBarButtonItem(customView: button)
      button.addTarget(self, action: #selector(ViewController.shareButtonPressed), for: UIControlEvents.touchUpInside)
  
      self.navigationItem.leftBarButtonItem = barButton
  </code></pre>
  
  <p>this code is inside the ViewDidLoad method. My problem is when I remove,</p>
  
  <pre><code>button.setImage(UIImage(named: "menu.png"), for: UIControlState())
  </code></pre>
  
  <p>it disappears the button but when I change the height and the width from,</p>
  
  <pre><code>button.frame = CGRect(x: 0, y: 0, width: 30, height: 23)
  </code></pre>
  
  <p>it changes nothing.
  My problem is how can I fix this bug. Any suggestion, answer is highly appreciated and if the given details are not enough, please mention. Thank you!</p>