ios - UIButton with rounded rects and custom backgroundImage when highlighted -


The problem is that my button is highlighted when displayed correctly. I should have background image blue, not opaque The code I use is presented below.

  Selfkbtnkleyrkbordavidth = 1.0 Selfkbtnkleyrkboardaersolor = Selfkbtnktintklor? .CGColor self.button.layer.cornerRadius = 5.0 self.button.layer. masksToBounds = true self.button.setTitleColor (UIColor.whiteColor (), forState: UIControlState.Highlighted) self.button.setBackgroundImage (self.imageWithColor (self.button.tintColor!, size: self.button.bounds.size), forState : UIControlState.Highlighted)  

and method for obtaining an image with a color.

  function imageWithColor (color: UIColor, size: CGSize) - & gt; UIImage {UIGraphicsBeginImageContextWithOptions (size, really, 1.0) color.setFill () var frame = CGRectMake (0, 0, size.width, size.height) UIRectFill (border) to image = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext () Return Image; }  


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -