I add background image to button in swift. The actual image size is 100x100. The idea is that when I click on the image, the popup of change profile image will appear. Then, you can choose photos from gallery and save.
After saving the photo, image shows fully. But, the problem is before I choose the photo from gallery, I set default image. Please see in following screenshot image.
Profile Female image should be big as background green color. Here is my code.
let img = UIImage(data: match.value(forKey: "imageData") as! Data )
btnProfile.frame = CGRect(x: 10, y: 100, width: 100, height: 100)
btnProfile.imageView?.contentMode = UIViewContentMode.scaleToFill
btnProfile.setImage(img, for: UIControlState.normal)
if(user_gender == "Female"){
btnProfile.setImage(UIImage(named: "femaleprofile_image")?.withRenderingMode(.alwaysOriginal), for: .normal)
btnProfile.imageView?.contentMode = UIViewContentMode.scaleToFill
}
Image size is 1@-> 40x40 px and 2@-> 80x80px.
Please anyone help me how to solve this problem.