title: How to set cornerRadius to UIImage inside a Button?
body: <p>I am creating Image with gradient, and i want the button to have cornerRadius</p>
  
  <pre><code>button = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton
          button.frame = CGRectMake(self.view.frame.size.width/2 - button.frame.size.width, 100, 250, 50)
          button.layer.cornerRadius = 3
          button.setTitle("ViewThree", forState: UIControlState.Normal)
          button.addTarget(self, action: "ViewControllerAction:", forControlEvents: UIControlEvents.TouchUpInside)
          button.setBackgroundImage(getImageWithGradient(UIColor(netHex:0x2d72cf).CGColor, bottom: UIColor(netHex:0x2d72cf).CGColor, size: CGSize(width: button.bounds.width, height: button.bounds.height), frame: button.bounds), forState: UIControlState.Normal)
  
  func getImageWithGradient(top: CGColor, bottom: CGColor, size: CGSize, frame: CGRect) -&gt; UIImage{
          var image = UIImage()
          UIGraphicsBeginImageContext(frame.size)
          var context = UIGraphicsGetCurrentContext()
  
          image.drawAtPoint(CGPointMake(0, 0))
  
          let colorSpace = CGColorSpaceCreateDeviceRGB()
          let locations:[CGFloat] = [0.0, 1.0]
  
  
          let gradient = CGGradientCreateWithColors(colorSpace,
              [top, bottom], locations)
  
          let startPoint = CGPointMake(frame.size.width / 2, 0)
          let endPoint = CGPointMake(frame.size.width / 2, frame.size.height)
          CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0)
  
          image = UIGraphicsGetImageFromCurrentImageContext()
          UIGraphicsEndImageContext()
  
          return image
  
      }
  </code></pre>
  
  <p>but no matter what i try there is no corner radius, how should i try this</p>