Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we create IBInspectable like checkmark?

I created lots of IBInspectable. But today, I observed that Xcode having some properties like this:

enter image description here

In the link, I marked rectangle box. I want to create custom IBInspectable like that. I don't know that is possible or not.

Any help would be appreciated.

like image 745
Sanjaysinh Chauhan Avatar asked Mar 16 '18 14:03

Sanjaysinh Chauhan


1 Answers

Follow below steps to create Custom IBDesignable

Step 1:

enter image description here

Step 2:

enter image description here

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:

enter image description here

Step 5: Here you get you custom fields

enter image description here

like image 121
Rohit Kardani Avatar answered Nov 20 '22 09:11

Rohit Kardani