Difference between revisions of "Extending Swift Classes"
Jump to navigation
Jump to search
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...") |
(No difference)
|
Latest revision as of 21:52, 16 October 2021
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()
}
}