I have images of size 320 x 480. I left a blank space at the bottom of these images to account for the tab bar at the bottom of the iPhone screen.
The 320 x 480 looks good on the iphone in portrait mode but it looks stretched on landscape mode.
These images are loaded programmatically.
What can I do to not having them look stretched and perhaps how to use a higher resolution.
My understanding is that a higher resolution means the image will be too big for the iPhone screen.
Thank you.
I presume you are using UIImageView. By default the contentMode property of any imageView is set to UIViewContentModeScaleToFill that means it will fill the entire view thereby stretching the image.
change this to - [imgView setContentMode: UIViewContentModeScaleAspectFit], what this does is to respect the aspect ratio of the image.
more here in apple docs
The screen Size of iPhone and iPad are given below. Based on the mode you can create image size.
iPhone:
Portrait : 320x460
Landscape : 480x300
iPad:
portrait : 768x1004
Landscape : 1024x748
Related
As A Begineer I've made a Puzzle game and it's working fine in Iphone Simulators.
But problem occurred when I run it in bigger Screen like IPad Air 2.All the picture aren't fitting perfectly in the buttons
(Note that Images are applied on buttons not in the Background of
buttons)
As image size not fit to given size of button, may be due to size concern of aspect fit property of imageview of button. You can try to scale image proportionally to size of imageview of button and get desire result.
You can refer to this link for scale image as proportionally to desired size.
scale Image in an UIButton to AspectFit?
I am making iOS 7 app where I am finding width and height in landscape mode.
What I have is below in app delegate...
NSLog(#"self.window.frame.size.width==%f", self.window.frame.size.width);
NSLog(#"self.window.frame.size.height==%f", self.window.frame.size.height);
What I was expecting is
self.window.frame.size.width==1024
self.window.frame.size.height==768
However I get reversed output as
self.window.frame.size.width==768
self.window.frame.size.height==1024
Note: I have ticked ONLY Landscape Left and Right. I have not selected Potrait & Upside Down.
Any idea why this is happening?
I am doing this on iOS 7.
The width and height of the screen and of the window in the screen don't change as the screen orientation changes, they will always be width = 768 and height = 1024 (until Apple makes an iPad with more pixels, like the height of iPhone's has changed).
In that screen window, you have a view controller with a root view. The size of that view will change with the screen orientation.
I have an app of photo catalog on my iPhone.
This app shows three images on screen with scrollview.
I want to enlarge/shrink the image size when I am scrolling.
I want to expand the image size when the image is centered.
And draw the image smaller when scrolled away from center to right/left.
I think this behaviour needs to developed in scrollViewDidScroll.
Do you know how to do this effect?
so you want a Coverflow ,
iCarousel may be the best control for it
take a look https://github.com/nicklockwood/iCarousel
In my iPhone app, I've put an image sized 480 x 44 in the navigation bar, but when I change to landscape, the image becomes shorter. Please someone help me.
The image size is reduced because the navigation bar has a different size in landscape mode and it crops the portrait one (44px height).
Should be 32 pixels in height in landscape.
I would make 2 different versions of the image (landscape and portrait mode) and then implement -willAnimateRotationToInterfaceOrientation to select the appropriate version.
In my iPhone app, my navigation bar image width does not change properly when transitioning to landscape. I'm using an image sized 480 X 34. Please, someone help me.
check your image size.....if less or more than make it 480*34