我是新手,我想在UIImageView周围设置黑色边框,但无法这样做。这是我的代码

@IBOutlet weak var flagImage: UIImageView!
var image = UIImage(named: "estonia")

override func viewDidLoad() {
    super.viewDidLoad()

    flagImage.layer.borderColor = UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 1.0).CGColor
    flagImage.layer.cornerRadius = 5.0

    flagImage.contentMode = .scaleAspectFit
    flagImage.image = image
 }

我可以在这方面得到一些帮助吗?

最佳答案


flagImage.layer.borderWidth = 2 /** as you wish **/

关于ios - 尝试设置UIImage的边框,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31339842/

10-08 20:35