I am trying to set an image to a button. For trying, I added an ImageView and a Button on the Storyboard. I connected both to my view controller.
@IBOutlet weak var testImage: UIImageView!
@IBOutlet weak var testButton: UIButton!
Then I try to fetch image online and set both. After fetching the data,
...
dispatch_async(dispatch_get_main_queue()) {
if let image = data {
self.testButton.setImage(UIImage(data: image), forState: UIControlState.Normal)
self.testImage.image = UIImage(data: image)
}
}
At this point, testImage sets the image just perfect but the testButton is turning into a blue rectangle.
What am I doing wrong?