Extending Swift Classes
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()
}
}