Extending Swift Classes

From PeformIQ Upgrade
Revision as of 20:52, 16 October 2021 by PeterHarding (talk | contribs) (Created page with " Here's one which show you how to extend a fundamental class in a way which adds new bits to the Xcode interface <pre> import UIKit @IBDesignable class CustomImageView: UIIm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here's one which show you how to extend a fundamental class in a way which adds new bits to the Xcode interface

import UIKit

@IBDesignable
class CustomImageView: UIImageView
{

    @IBInspectable var borderWidth: CGFloat = 0.0
        {
        didSet {
            self.layer.borderWidth = borderWidth
        }
    }
    
    
    @IBInspectable var borderColor: UIColor = UIColor.clear
        {
        didSet {
            self.layer.borderColor = borderColor.cgColor
        }
    }
    
    override func prepareForInterfaceBuilder()
    {
        super.prepareForInterfaceBuilder()
    }
        
}