Reputation: 6790
So I am using the following code to create a rounded image from a Facebook profile image.
The issue is when iOS switches to dark mode it has these white corners which should not be there. I am wondering how do I get rid of this white background since it should be the background color of the navigation bar which changes depending on day or night.
let fbID = ((result! as AnyObject).value(forKey: "id") as? String) ?? ""
let facebookProfileUrl = "http://graph.facebook.com/\(fbID)/picture?type=large"
print(facebookProfileUrl)
//GRAB IMAGE AND TURN TO BUTTON
let fburl = URL(string: facebookProfileUrl)
// Image needs to be added to project.
self.button.frame = CGRect(x: 0, y: 0, width: 31, height: 31) //set the frame
let fbs = CGSize(width: 31, height: 31)
let processor = DownsamplingImageProcessor(size: fbs)
|> RoundCornerImageProcessor(cornerRadius: 20)
let modifier = AnyImageModifier { return $0.withRenderingMode(.alwaysOriginal) }
self.button.kf.setImage(with: fburl,for: .normal, options: [.processor(processor),.imageModifier(modifier)])
self.button.addTarget(self, action: #selector(FirstViewController.signOut(_:)), for: .touchUpInside)
let barButton = UIBarButtonItem()
barButton.customView = self.button
self.tabBarController?.navigationItem.rightBarButtonItem = barButton
//END FACEBOOK PROFILE IMAGE
Upvotes: 1
Views: 431
Reputation: 127
Try This, I hope this may be helpful to you.
self.button.frame = UIImageView(frame: CGRect(x: 0, y: 0, width: 31, height: 31));
let roundCornerIP = RoundCornerImageProcessor(cornerRadius: 20);
self.button.kf.setImage(with: fburl,options: [.processor(roundCornerIP),.cacheSerializer(FormatIndicatedCacheSerializer.png)]);
let barButton = UIBarButtonItem();
barButton.customView = button;
self.tabBarController?.navigationItem.rightBarButtonItem = barButton;
Upvotes: 2