My suggestion is.
Instead of set size of image you should set size of UIImageView
and then put this image on it so, size of image will be display as per your requirement.
Such like,
var imageView = UIImageView(frame: CGRectMake(100, 150, 150, 150)); // set as you want
var image = UIImage(named: "myImage.png");
imageView.image = image;
self.view.addSubview(imageView);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…