UIView-এর বর্ডার কালার এবং মোটা (thickness) পরিবর্তন করার দুটি পদ্ধতি —
পদ্ধতি ১: সরাসরি কোডিং
backView.layer.borderWidth = 5 backView.layer.borderColor = UIColor(red: 0.09, green: 0, blue: 0.30, alpha: 1).cgColor
ফলাফল —

পদ্ধতি ২: @IBDesignable এবং @IBInspectable এক্সটেনশন
@IBDesignable class DesignableView: UIView { }
extension UIView {
@IBInspectable var borderWidth: CGFloat {
get { return layer.borderWidth }
set { layer.borderWidth = newValue }
}
@IBInspectable var borderColor: UIColor? {
get { if let c = layer.borderColor { return UIColor(cgColor: c) }; return nil }
set { layer.borderColor = newValue?.cgColor }
}
}
স্টোরিবোর্ডে লাইভ প্রিভিউ —
