I have a
let picture = UIImageView(frame: imageFrame)
picture.image = UIImage(named: image)
let frame = CGRect(x: 0, y: CGRectGetMaxY(menuLine.frame) + HeightForSize * 0.05, width: view.bounds.width, height: HeightForSize * 0.9)
let mask = UIView(frame: frame)
mask.backgroundColor = UIColor.whiteColor()
picture.maskView = mask
UIImageView respects contentMode which would likely serve your purpose here easier than a mask. Set your imageView to the fixed size you want all images to fit in. If you want the image to squeeze in and show black bars if its too tall for example, use
UIViewContentMode.scaleAspectFit. but more likely what will look best is
UIViewContentMode.scaleAspectFill. It will maintain the aspect ratio of your image and scale until it fills the imageView box you've created. Play with the two modes and others to see their effects.
let imageView = UIImageView(image: UIImage(named: "myImage")) imageView.frame = CGRect(x: 0, y: 0, width: 100, height: 100) imageView.contentMode = .scaleAspectFill
More info on various contentModes you can try here.