Extending Swift Classes
Revision as of 21: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...")
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()
}
}