I have a design for app where Tabbar looks like this:
I tried to add TabBarController and change its background but TabBar's background has only original size of image that looks bad on different iPhone models.
The next idea was to add a View on the bottom MainView and add UIImageView in bottom View. It looks nice but only on iPhone 7/8. On another models it looks bad because they have different width and height.
You can use aspect ratio for handling different device resolution for tabbar view. So it will create tabbar with different height and width for each device as per its size.
You can refer below links for aspect ratio:
Autolayout aspect ratio for UIImageView / UIView
Related
In my Launch Screen.storyboard, I have a UIImageView named LaunchScreenIcon that scales proportionally to the width of the screen by setting the LaunchScreenIcon.width = width constraint.
Is it somehow possible to change the behavior for landscape orientation so that the height of the UIImageView scales to the height of the screen i.e. LaunchScreenIcon.height = height?
Constrain your image view to 0 on all four sides (so it fills the entire view), then set its Content Mode to Aspect Fit
That should give you what you want.
I was able to accomplish this by:
Going to my Launch Screen.storyboard
Selecting the large iPad model in landscape from the panel at the
bottom
Tapping "Vary for Traits" to the right and checking off both width
and height
Then I added the constraint as I normally would and it was now only
associated with the large iPad model in landscape
I have a UIImageView in a Storyboard. The image used is square. The imageView width and height are equivalent. I want to take advantage of Autoresizing in Storyboard, so that on a small device the image is scaled down and on a large device the image is scaled up. When I test on a iPhone 5 the scaling is appropriate. However, when running on a iPad the results are different. The square is stretched, and this makes sense as the dimensions of the screen is different to the dimensions of the iPhone. How can I avoid this issue, is there a process in which I can scale the view as a whole up until the height is the same as the height of an iPad and then centre the view?
Note - The image has the same width and height and the content mode is set to 'Aspect Fit'
Follow this procedure
1) add a view in which all your content will be added so now you going to use 2 views NewView[with Content] and baseView
now time to add constraints to newView Do like this for leading, trailing,bottom and top [adding wr hr component]
Result For iPad
result for iPhone
I have some views in my app which need to keep always the same aspect ration.
For example I have one view which should always have the width = 2 * height but when I resizing for Ipad the width increase too much and the aspect ration is lost.
It is a way to do that with auto-resizing? Or I should calculate manually for every screen?
Thanks in advance!
EDIT!
This is a screenshot with my view controller.
There are some images. The hover for last 3 items is an UIView with background color. Images are Aspect to Fit content mode. When the Ipad autoresizing the views, images are keep the aspect fit of Image but the view used for hover is not.
Something like this happened:
i have 2 UIView in horizontal view. its both UIView size is 141 x 192.when i run in 5s screen the two view are in perfect. But when i run in 6,6s my UIView width is stretched. not able to see the correct width.
so how to code - use the screen size and display the correct width and hight equal for all screen using objective c
i used storyboard to fix 2 UIView. i am new to ios. how to code the UIView with position and also the aspect ration of screen size to see my UIView equal for all screen
You can use autolayout and size classes for making user interface for multiple screen. First enable autolayout and size classes
Then you can give your views proportional width and height. For example in your case both view width will get 50% of screen width.
Since this is very detail topic. I will share a very simple and beginner tutorial.
http://www.raywenderlich.com/115440/auto-layout-tutorial-in-ios-9-part-1-getting-started-2
Follow the tutorial and learn how to use autolayout.
How do I increase the width of two image views which are located inside a main view to landscapeorientation through a UIInterface nib file from portrait orientation, where the sizes of image view are different to one another?
I need a increase in width proportional to their default size.
Explain by setting a constraint in the nib file.
example, my image view1 is in left corner of the main view and image view2 is in right corner of the main view.both of same height but width is different.first it is in portrait i am setting this in nib file.while running by changing the portrait view into landscape either any one of the sizes gets increased.but my requirement is need to expand the width of both image view from their original width size in correct ratio.for this how to set the constraint in nib file
the image for my requirement
as in portrait orientation,
and i need in landscape orientation as,
here one more doubt was that cant make correct streching size too in horizontal orientation for that orange and white (height i am mentioning here) colour image views.
Use autosizing functionality.
For more info try this link:
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2