I'm using a storyboard with some compoments like labels and buttons. The problem is that the captions are too big for my mobile display so the last words will be cutted.
I noticed that the font size seems a little bit bigger than in other apps so I want to ask what the default font size is?
And if I reduce the font, however, there may be problems on various devices, e.g. the presentation on an iPhone or an iPad?
Is it necessary to create different storyboards, each one for every device or what is the usual procedure?
There is an option called "minimum font scale" which may be useful, and there is this built-in functionality to adapt your UI to different devices:
https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/TheAdaptiveModel.html#//apple_ref/doc/uid/TP40007457-CH19-SW1
And a tutorial from a site that has helped me wrap my head around a lot of iOS concepts (this is the one I used, got updated for ios11)
https://www.raywenderlich.com/162311/adaptive-layout-tutorial-ios-11-getting-started
Solution With Xcode 9:
Xcode story board has an options to separate configuration for User Interface Elements for different size (iPad & iPhone) and different orientation (Landscape and Portrait), which are Any, Compact, Regular integrated with Size Class.
Size class also allows to set different font size for iPhone & iPad.
Follow these steps, for easy under standing, how to use Size class to solve your problem.
Add label in your story board - view controller layout
Select label and open 'Attribute Inspector'
There is a small '+' icon on left side of 'Font' attribute. Click on '+' icon. It will give you a small popover with size options for your label font.
For iPhone it will show you compact width and regular height by default set/selected. Now change/set height and width both as Regular and Click on 'Add Variation', which will add a new variation for font size for iPad (a device with regular height and width).
Change font size from 17 to 40 for variation with 'wR x hR' (As shown in this snapshot)
Here is result of variation in iPhone and iPad
Related
I have got rather general question about making Adaptive Layout in iOS App.
When creating new project in Xcode you have ability to choose with which screen size you can start working:
I have noticed that if you place a square UIView on iPhone SE screen and then connect Leading, Trailing, Top and Bottom constraints - this view displays correctly on every other screen. But if you perform same actions on iPhone X, then this same shape would be corrupted on smaller screens.
So, my questions are:
Which iPhone screen size to choose, when starting making iOS app in
order not to face headaches with constraints on other screens and to
make pixel perfect UI?
If I receive design prepared for iPhone X screen, can I prepare it
firstly for iPhone SE screen and will it be displayed correctly on
bigger screens in this case?
What are screen sizes you use in your projects most frequently?
Actually there is no difference in choosing which 1 , what you need is to make your thoughts when making constraints to be generic , and that means every static width/height will appear similar in all devices , and every proportional 1 will look according to the device size , personally i like to use iphone 5 ( please forget about iphone 4 or you'll have to make the main view a scrollview because of the very small height of that device ) , also you can toggle the device to see how the constraints you set ( in the choosen 1 ) are look in the other device
You don't need to 'choose' a size. This is just a display setting and you can change it at any time to preview your layout on different devices.
You need to make your constrains in a logical way that will naturally adapt when change screen sizes.
I'm having problems with app elements clashing together on the smaller iPad size. Is there a way to resize the fonts so they're not so large in iPad? Samples below:
App Screen on iPhone:
App Screen on iPad:
If you are using Storyboard, then use auto layout properly to avoid overlapping in smaller screen sizes. Firstly, you should give minimum distance between each element.
Secondly, for LABELS, there is a property Autoshrink in Attributes Inspector which when set to Minimum Font Size gives the ability to shrink the text size with the screen size accordingly.
For Text Field's, there is a property Min Font Size in Attributes Inspector which helps shrink font sizes accordingly.
This can work in conjunction with the answer of #Vikash Kumar
Select your label in your storyboard. In the attributes inspector you will see a small '+' to the left of the font selector. This will allow you to choose size-class specific stuff for your text.
Size classes were added to iOS 8 when Apple introduced Universal Storyboards which let you design for both iPad and iPhone with the same Storyboard file. At the bottom of the Storyboard design window you'll see the (default) 'w Any h Any' button. This gives you access to combinations of the compact and regular size classes. These available combinations let you implement design, say for only the iPhone in landscape, or maybe the iPad in both orientations. You have full control.
For your font related question, you access the size-class control through the '+' sign I mentioned above.
This is a good explanation and tutorial: Wenderlich size classes
and in Apple's explanation: Apple size classes
I've this big problem. iPhone 7 and SE uses the same size classes, so I cannot edit the constraints of SE. When I launch SE simulator, the app isn't optimized..in what way can I solve this problem?
If you have a label that is showing "some text..." on SE. There are a few ways you can solve this.
You could allow that label to be multiline
You could choose different text based on width
You could measure the text and if it's too big, use shorter text
You could pick something that fits on all widths
You could use the auto-font sizing features of labels
You could pick a font size yourself from the width or by measuring.
Constraints/Size-classes are not the only tool you can use for a responsive design.
The point of using size classes is not to solve this kind of problem -- it's to have a completely different UI -- like you show side-by-side panes on iPad and a navigation controller on iPhone.
I'm new to ios(android dev). I'm using storyboard, and autolayout.
To optimize application for tablet, i used sizes in storyboard regular width regular height.
I want to align ui items on ipad different than on iphone mode. For example, i have a table of textfields that occupy full width on iphone. On ipad i want to place two or three textfields in one cell. How can i make different ui implemetation for ipad, so the logic shoudl stay the same.
I watched https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LayoutandAppearance.html#//apple_ref/doc/uid/TP40006556-CH54-SW1
But there is no answer there.
Jenya Kirmiza,
Size Class is what you want :) Size classes were introduced with iOS8 in order to avoid the multiple storyboards for universal applications and yet provide an easy way for the developer to design differrent UI for differrent Devices :)
I expect you to know SizeClasses, In case you are not aware each device in its various orientation falls to one of the sizeClass defined by Apple.
One thing important to note here is that iPad in its both the orientation falls to Regular x Regular size class
Where as all iPhones other than iphone 6S and iphone 6s + will fall to
Copact Width x Regular Height - Portrait mode
Compact Width X Compact Height - Landscape Mode
Iphone 6s and 6s + falls to
Copact Width x Regular Height - Portrait mode
Regular Width X Compact Height - Landscape Mode
Now that you are equipted with the information of all size classes lets nail this issue down. When you open the story board at the center of the screen there is option to decide the size class :)
So go ahead open up your story board when you see it by default will be in wAny wAny mode What it means is whatever the components you add and add the constraint to it will be applicable to all the sizeclasses irrespectively.
Hence you see the textField added at the center of the screen appears center in all the devices may it be iPhone ot iPad.
For explaining Ill add two text fields named Firstname and LastName :)
Lets start adding textFields and constraints to them in storyboard keeping wAny wAny mode.
Now I have added two textFields one below the other covering the whole width of the screen in any any mode :) This will work fine for me in all iPhone devices :)
But I want to allign them side by side in iPad. Now we know that iPad belongs to Regular x Regular sizee class in both the orientation :)
So Simply change the size class in storyBoard
Now when you see you will see two textfields added one below the other already :)
Now select those textfields we want to align them differently isnt it :) So will have to remove the constraints already added to them :)
Now move them place next to each other add constraints properly :)
Thats it now run on iPhone and iPad :) You will textFields one below each other in iPhone and one next to other in iPad :)
iPhone Output :
iPad output :
Hope this helps :)
I'm developing iOS 8 universal app, I'm using adaptive layer to develop app, all going well.
But, I struck at iPad design, because I used equal width and height for all devices using constraints, its looking good for iPhone devices, but iPad also is showing as like iPhone design, so I need to increase button sizes, so can I use a separate constrains for iPhone and iPad buttons on single storyboard app in iOS 8 with Swift language.
One more doubt is, how to handle dynamic buttons on same storyboard application with auto layouts and constrains
Thanks in Advance.
You can select Regular width|Any Height size class and set the size and constraints for the button specific to iPad. According to Apple docs :
Views, constraints, and fonts are added from the size classes in the same way they would be chosen for display on a screen. Items from Any|Any are used unless those items are changed or uninstalled in more specific size classes. In that case, the most specific item is used. For example, in the iPhone nib, modified items in the Compact|Regular size class take precedence over items in Compact|Any. And modified items in Compact|Any take precedence over items in Any|Any.
Regular width|Any Height size class is taken in run time for iPad and Any|Any is taken for iPhone.