Swift 圆形图像的白色背景

Swift white background from rounded image

所以我使用以下代码从 Facebook 个人资料图片创建圆形图像。

问题是当 iOS 切换到深色模式时,它有这些不应该出现的白角。我想知道如何去掉这个白色背景,因为它应该是导航栏的背景颜色,会根据白天或晚上的不同而变化。

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 [=11=].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

尝试一下,希望对您有所帮助。

    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;