title: How do you set the height and width of a UIButton with image
body: <p>This is driving me nuts. I have looked everywhere and cannot figure this out. Check it out...</p>
  
  <pre><code>    let findMeButton = UIButton(type: UIButtonType.System)
  
      findMeButton.translatesAutoresizingMaskIntoConstraints = false
  
      findMeButton.setImage(UIImage(named: "locateMe"), forState: UIControlState.Normal)
  
      findMeButton.addTarget(self, action: #selector(MapViewController.findUserLocation(_:)), forControlEvents: UIControlEvents.TouchUpInside)
  
      view.addSubview(findMeButton)
  
      // I added this line of code and it still doesn't work.
      findMeButton.frame.size = CGSizeMake(50, 50)
  
      findMeButton.bottomAnchor.constraintEqualToAnchor(bottomLayoutGuide.topAnchor, constant: -10).active = true
  
      findMeButton.trailingAnchor.constraintEqualToAnchor(margins.trailingAnchor, constant: 5).active = true
  </code></pre>
  
  <p>I am still learning iOS. How do you set the Height and Width of this UIButton with an Image. Everything I have tried has given me an error or just didn't work. I am still trying to rap my head around what  translatesAutoresizingMaskIntoConstraints does. I just simply want to have the Button where it is but change its size (Height &amp; Width). </p>
  
  <p>Thanks in advance</p>
  
  <p><strong>EDIT:</strong> I have changed the bit of code to this</p>
  
  <pre><code>    // Locate user button
      let locateButton = UIButton(type: UIButtonType.System) as UIButton
  
      locateButton.frame = CGRectMake(0, 0, 50, 50)
  
      locateButton.setBackgroundImage(UIImage(named: "locateMe"), forState: UIControlState.Normal)
  
      locateButton.addTarget(self, action: #selector(MapViewController.findUserLocation(_:)), forControlEvents: UIControlEvents.TouchUpInside)
  
      view.addSubview(locateButton)
  </code></pre>
  
  <p>I want to position the button to the windows bottom and right margin. I also want to set the image dimensions to height 50 x width 50. How would I accomplish this?</p>
  
  <p><strong>EDIT 2:</strong> I figure you have to use Auto Layout to do so but can someone show me how. Everything I have done hasn't worked.</p>