Ios 使用圆形图像更改UIImageView的背景色

Ios 使用圆形图像更改UIImageView的背景色,ios,swift3,uiimageview,Ios,Swift3,Uiimageview,我想更改UIImageView占用的空间的背景色,它有一个圆形图像,因此在视图周围有空白。 下面是一个我想要实现的粗略想法的示例,但我似乎无法实现,更改imageView.backgroundColor或imageView.tintColor似乎不起作用 这些是我关于UIImageView的代码片段 @IBOutlet weak var imageView: FUIImageView! var prodImage: UIImage! override func viewDidLoad

我想更改UIImageView占用的空间的背景色,它有一个圆形图像,因此在视图周围有空白。 下面是一个我想要实现的粗略想法的示例,但我似乎无法实现,更改imageView.backgroundColor或imageView.tintColor似乎不起作用

这些是我关于UIImageView的代码片段

@IBOutlet weak var imageView: FUIImageView!
var prodImage: UIImage!

    override func viewDidLoad() {
        super.viewDidLoad()

        if prodImage != nil {
            self.imageView.image = prodImage
            self.imageView.contentMode = .scaleAspectFit
            self.imageView.isCircular = true
            self.imageView.borderColor = UIColor.preferredFioriColor(forStyle: .positive)
            self.imageView.borderWidth = 1.0
        }
        else{
            self.imageView.image = UIImage(data: try! Data(contentsOf: URL(string: "https://spotlight.dlme.clir.org/assets/default-52adc3dc03639885e8aa93763e29868269dd3b9dad4689f140c0175b4f945922.png")!))!
            self.imageView.contentMode = .scaleAspectFit
            self.imageView.isCircular = true
            self.imageView.borderColor = UIColor.preferredFioriColor(forStyle: .negative)
            self.imageView.borderWidth = 1.0
        }


        self.tableView.rowHeight = UITableViewAutomaticDimension
        self.tableView.estimatedRowHeight = 44
    }

为什么不能使用.png图像并向图像视图添加背景色。这就行了。这个方法应该行得通,但imageView的类被更改为某些SAP imageView类,该类会阻止背景色出现,因此您需要将该类更改为默认UIImage类,以使您的想法正常工作。为什么不能使用.png图像并将背景色添加到图像视图中。这样就行了。这个方法应该可以工作,但是imageView的类被更改为某些SAP imageView类,该类会阻止背景颜色出现,因此您需要将该类更改为默认UIImage类,以便让您的想法正常工作。