I want just this simple effect:
that I have a picture automatically orients itself according to the device/screen orientation, it alway fill up the whole screen without stretching itself so that the aspect doesn't change.
I work with Xcode though I got a lot of answer with storyboard and UI builder,I really don't like such ways that work well but you have no idea how it works, so I was trying to find the way to do it programmatically instead.
I've tried to set a image view as subview, but it doesn't fix well after the device is rotated, it either stretch to fill the screen or move to somewhere else with size unchanged (when I trie to recalculate the frame and apply to the subview), then I tried to override the drawrect func, of the UIView, the frame works fine but the animation of rotating is broken (it stretches it self during the rotation and then skip into the final frame).
the perfect effect I want is just like iOS original photo app, when I check a photo, it resizes to fix the screen, and even when I rotate the screen, the animation works just perfect, the rotating and scaling happens in the same time and no skip of stretch happens. could anyone please give me some help?
THANKS!!!!!
the way I set the frame:
func locating (imgsize:CGSize,scrsize:CGSize) ->CGRect {
var size:CGSize
var ori:CGPoint
if ((imgsize.height / imgsize.width) * scrsize.width>=scrsize.height){
size = CGSize(width:scrsize.width,height:imgsize.height*(scrsize.width/imgsize.width))
ori = CGPoint(x:0,y:scrsize.height-imgsize.height*(scrsize.width/imgsize.width))
}
else {
size = CGSize(width:imgsize.width*(scrsize.height/imgsize.height),height:scrsize.height)
ori = CGPoint(x:-(imgsize.width*(scrsize.height/imgsize.height)-scrsize.width)/2,y:0)
}
return CGRect(origin:ori,size:size)
}