I'm trying to understand how to call from another class for example let creation = menuButtonController(image:#imageLiteral(resourceName: "maps"))
then in menuButtonController
i set this:
class menuButtonController: UIView {
let buttonView = UIView()
let button = UIButton(type: .custom)
var imageButton: UIImageView
init(frame: CGRect, image: UIImage) {
super.init(frame: frame,image: image) //Cannot invoke UIView.init with an argument list of type (frame cgrect, image uiimage)
self.imageButton.image = image
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
/* other functions */
}
it give me a error that i'm not able to solve. can anyone helps me?
Edit
now if i want to call only initializer with (image: UIImage)
should i use a convenience init
like this right?
convenience init(image: UIImage) {
self.init(image: image)
self.imageButton.image = image
}
it don't give me errors but crash when i try to run the application