Hi guys
I'm using auto layout. I put an image inside an UIImageView. This imageView is positioned using auto layout. As long as I am using a natural image all is fine. Of course when no image was provided I want to add a plus sign. This plus sign gets stretched because the imageView is using scaleToFill. So I decided to put this code inside viewDidLayoutSubViews():
This code works fine. Till I rotate the device. Then it's stretched all over again. If I use the same technique inside didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) the imageView keeps getting smaller and shifting. Anyone got a suggestion how I solve the rotating part? Thanks!
I'm using auto layout. I put an image inside an UIImageView. This imageView is positioned using auto layout. As long as I am using a natural image all is fine. Of course when no image was provided I want to add a plus sign. This plus sign gets stretched because the imageView is using scaleToFill. So I decided to put this code inside viewDidLayoutSubViews():
Code:
self.wifeImageView.frame = CGRectMake(self.wifeImageView.frame.origin.x + self.wifeImageView.frame.height * 2/3, self.wifeImageView.frame.origin.y + self.wifeImageView.frame.height * 1/3 , self.wifeImageView.frame.height * 2/3, self.wifeImageView.frame.height * 2/3)
}
self.wifeImageView.contentMode = UIViewContentMode.ScaleToFill
self.wifeImageView.clipsToBounds = true
self.wifeImageView.image = UIImage(named: "Plus")
This code works fine. Till I rotate the device. Then it's stretched all over again. If I use the same technique inside didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) the imageView keeps getting smaller and shifting. Anyone got a suggestion how I solve the rotating part? Thanks!