I have tried so many times to just get a simple border on an ImageView but nothing seems to work. Those are my active settings now:
But the result is still without any border.
What am I missing in my settings?
I have tried so many times to just get a simple border on an ImageView but nothing seems to work. Those are my active settings now:
But the result is still without any border.
What am I missing in my settings?
 
    
     
    
    layer.borderColor is a CGColorRef. But interface builder passes a UIColor. You have two options:
1 - Set the border color in code:
self.imageView.layer.borderColor = UIColor.blue.cgColor
2 - Extend UIImageView or UIView with a borderColor property and use @IBDesignable and @IBInspectableso that property is visible in interface builder. Use this new property as a proxy to layer.borderColor.
@IBDesignable
extension UIView {
    @IBInspectable
    var borderColor: UIColor? {
        get {
            if let cgColor = self.layer.borderColor {
                return UIColor(cgColor: cgColor)
            }
            return nil
        } set {
            self.layer.borderColor = newValue?.cgColor
        }
    }
}
Related Posts:
