Follow below steps to create Custom IBDesignable
Step 1:
Step 2:
step 3: add this code in created customTextView file
import UIKit
@IBDesignable
class customTextView: UITextView {
@IBInspectable var cornerRadius: CGFloat = 4.0 {
didSet{
layer.cornerRadius = cornerRadius
}
}
@IBInspectable var borderWidth: CGFloat = 0.0 {
didSet{
layer.borderWidth = borderWidth
}
}
@IBInspectable var borderColor: UIColor = UIColor.clear {
didSet{
layer.borderColor = borderColor.cgColor
}
}
@IBInspectable var shadowOpacity: Float = 0 {
didSet{
layer.shadowOpacity = shadowOpacity
}
}
@IBInspectable var shadowColor: UIColor = UIColor.clear {
didSet{
layer.shadowColor = shadowColor.cgColor
}
}
@IBInspectable var shadowOffSet: CGSize = CGSize.zero {
didSet{
layer.shadowOffset = shadowOffSet
}
}
}
Step 4:
Step 5: Here you get you custom fields
@IBInspectable
will give you an on/off drop-down control in the inspector. – Dian