I have been trying to adjust an image's size in NSImageView
programmatically. There doesn't seem to be any way to do so. The image ends up being quite large and there is no way to adjust it. I want to adjust it to a 40 (width) by 40 (height).
Here is the image view created programmatically:
let theImg: NSImageView = {
let imageView = NSImageView()
imageView.image = NSImage(named: "my-logo")
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()
Here are the constraints for the image:
view.addSubview(theImg)
theImg.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 280).isActive = true
theImg.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
theImg.topAnchor.constraint(equalTo: view.topAnchor, constant: 50).isActive = true
I'd appreciate those who would be willing to help or at least give some hints if possible.