将 Facebook 图像设置为按钮背景

set Facebook image as button background

所以我有以下

let profilepicURl = "https://graph.facebook.com/\(user_id_fb)/picture?type=large" //user_id_fb like 1251246454544 your facebook ID

但我想做的是将 url 图片放在下图所在的位置 我想我可以使用 import Kingfisher 因为我已经将它与应用程序集成,但我不确定如何实现我在寻找什么。

// Image needs to be added to project.
         let buttonIcon = UIImage(systemName: "person.circle")

        let rightBarButton = UIBarButtonItem(title: "Person", style: UIBarButtonItem.Style.done, target: self, action: #selector(FirstViewController.checkLogin(_:)))
         rightBarButton.image = buttonIcon

          self.tabBarController?.navigationItem.rightBarButtonItem = rightBarButton

我试过以下方法

let rightBarButton = UIBarButtonItem(title: "Person", style: UIBarButtonItem.Style.done, target: self, action: #selector(FirstViewController.checkLogin(_:)))
                    rightBarButton.kf.setImage(with: facebookProfileUrl, for: .normal, placeholder: nil, options: [.imageModifier(modifier)], progressBlock: nil, completionHandler: nil)
                    //rightBarButton.image = buttonIcon

                      self.tabBarController?.navigationItem.rightBarButtonItem = rightBarButton

但是 returns

Use of unresolved identifier 'modifier'

创建一个自定义按钮并将其设置为 UIBarButton 并将图像设置为按钮。

  let button = UIButton()
  button.frame = CGRect(x: 0, y: 0, width: 51, height: 31) //set the frame
  let modifier = AnyImageModifier { return [=10=].withRenderingMode(.alwaysOriginal) }
  button.kf.setImage(with: url, for: .normal, placeholder: nil, options: [.imageModifier(modifier)], progressBlock: nil, completionHandler: nil)
  button.addTarget(self, action: Selector("yourActionFunc"), for: .touchUpInside)

  let barButton = UIBarButtonItem()
  barButton.customView = button
  self.navigationItem.rightBarButtonItem = barButton