0

can someone help me please, I'm trying to customize a UIButton I made a "setup" function but I would like a parameter to allow me to modify the borderColor. I don't know how to initialize the borderColor property here is the code:

`

import UIKit

class MyBouton: UIButton {
    
    let borderColor: UIColor  // property that I would like to initialize
        
    override init(frame: CGRect) {
        super.init(frame: frame)
        setup(borderColor: <#UIColor#>)
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setup(borderColor: <#UIColor#>)
    }
    
    func setup(borderColor: UIColor) { // function in which I want to use the property
        layer.cornerRadius = 10
        layer.borderWidth = 2
        layer.borderColor = borderColor.cgColor
    }
}

`

Bilal Yyy
  • 1
  • 3
  • Check this out: https://stackoverflow.com/questions/27079681/how-can-i-init-a-uibutton-subclass – fmmb Nov 02 '22 at 09:02

0 Answers0