Good afternoon, I'm learning swift and I want to place an image but I still don't know how to do ,it with label it was easy.
class NotificationView: MessageView {
private let detalleSolicitudes = UILabel(text: "¡Hola! tienes mas de una solicitud", font: .poppins(size: 12), textColor: .greenSanna(), textAlignment: .center, numberOfLines: 1)
//MARK:- "search" is the image I have in my Assets
private let imagenSolicitud: String = "search"
private let solicitud = UILabel(text: "Title test", font: .poppins(size: 12), textColor: .greenSanna(), textAlignment: .center, numberOfLines: 1)
private let fechaHoraSolicitud = UILabel(text: "Title test2", font: .poppins(size: 12), textColor: .greenSanna(), textAlignment: .center, numberOfLines: 1)
private let button = UIButton(title: "Ir al estado de la Solicitud", titleColor: .red)
override init() {
super.init()
//this does not allow me
addView(view: imagenSolicitud)
addView(view: detalleSolicitudes)
addView(view: solicitud)
addView(view: fechaHoraSolicitud)
button.addTarget(self, action: #selector(handleButton), for: .touchUpInside)
}
func Solicitud(_ text: String) {
self.solicitud.text = text
}
func FechaHoraSolicitud(_ text: String) {
self.fechaHoraSolicitud.text = text
}
@objc func handleButton() {
closeMessageView()
}
}
CodePudding user response:
private let myNewImageView = UIImageView(image: UIImage(named: imagenSolicitud))
This will create you UIImageView. But maybe still need to add frames or constraints to see the result. Depending on the context.