Automatic scaling of fonts in iOS? - ios

I'm a UX designer working with a handful of developer teams. We're having an issue with what I believe to be a lot of hard coded values for fonts (as well as other things). The end result being that if a user changes their font size on their phone, or if the app is loaded on a smaller phone like a 4 or 5, the whole design breaks.
I am just beginning to read up on it, but it seems that there's a proper way to build screens and handle text so that it adapts to both device size and user font settings without things breaking (like text overlapping, text boxes bumping into each other, or just flat out text sizes not changing/adapting when they should.)
It seems that the new San Francisco font helps somewhat with this, although we have not been able to implement it yet (again, too much hard coded stuff).
I wonder if someone could lay out the proper strategy for handling text at multiple device sizes and user settings. I am assuming it has something to do with Adaptive Layout. I need to be able to go back to the team and intelligently have the conversation.

You will have to use adjustsFontSizeToFitWidth property of UILabel. For details have a look at this.

Related

Is there a Cocoapod/Standard way that allows user to change the font size within the app like the one in iBooks app in Swift?

I am trying to implement a font size changer functionality similar to the one provided by the iBooks app in iPhone.
I know how to set the font using Dynamic Type when Text Size changes at the phone level, but the requirement here is to allow the user to change the font size within the app, and update the content as per the new font size.
(I need to change the brightness and the font size only.)
I looked over the net and found this link
This link shows a manual way of doing it. I was wondering if this a common requirement among apps and is there a standard way/cocoa pod to do this?
Thanks in advance.
Been a Java developer for about 8 years, and was used to using the term "library" which I believe didn't make much sense in the iOS world.
I was looking for something that lets me change the font size and the screen brightness in one shot since I thought it would be a common requirement in most of the reading apps. Something like this :
Since I didn't find anything, and like #WTEDST mentioned saying it requires few lines of code, I went ahead and
Added a view(B) on top of my main view(A)
Showed this view(B) only on clicking of the ᴀA button
This view(B) contained the slider component and 2 buttons at the bottom for increasing and decreasing the font size.
I added a method to change screen brightness on moving the slider and another method on each of the increase/decrease font buttons.
Used a UIStackView to arrange the items nicely.
Done.

How to prevent "bigger text" (font scaling) on iPhone

Ive been looking around to find an answer, but all I can find is related to web scripting, so...
We are testing an app, and it seems that one user had "increased text size (from phone settings)," but the only texts that are actually increased are the cells of tableviews? I don't understand why the text are not increased in any other place (but I thank the coding god), since it is indeed increased in tableviews?
Anyway, can someone help me on how to fix this so that my tableviews hold a static font size?
Probably the developers set defined size for most of the labels. They should use system size to make it work properly.

How would you create a user interface for an iOS app for devices of all sizes?

When creating an application is it possible to just get the dimensions of the device's screen and then to divide the dimensions by a number so that all UI elements will look similar on all devices?
I know that this can obviously be done, but is it something I should consider doing? Or should I consider creating multiple storyboard files to cover every single iOS device? Or is there a feature that storyboards have that allow you to do this and I just haven't discovered it yet?
If you set the sizes of UI elements to specific numbers (and not ratios) when you are programmatically adding the UI elements, the whole screen will look a bit off when you use a different device with a different screen size. So if I wanted to create user interfaces for all devices programmatically (without storyboards) would I have to write different code for each device? This is why I'm wondering if it would be better to just use ratios for the sizes. By doing that you will only have to write the code once.
Which way is best for designing for all screen sizes?
When creating an application is it possible to just get the dimensions
of the device's screen and then to divide the dimensions by a number
so that all UI elements will look similar on all devices?
No. It's proper only where it fits. Sometimes there's a situation which allows this scenario, but usually not. Because absolute size and proportion of devices are all different, and different layout needs different behaviors and interactions.
Think in users' perspective. Would you like to use such app? Well if you don't need UX quality, it's fine to do whatever.
There's no magic. Strictly saying, in worst case scenario, you need to always be prepared to write separated version of layout code for every each devices. If you have situations which can share a layout code (using whatever techniques), that's just lucky.
To optimize production, you can try to group devices in similar proportion. Apple calls this layout-idiom. Usually iOS devices builds two group --- phones and pads. In this case You need to make sure that all the UI components to support minimum range of flexibility in layout to deal with extra screen proportion fragmentation. Utilize
Manual programmatic layout
NSLayoutConstraint
for this.
In my experience, this is the most time-saving approach. Sometimes just making all version of layout is better, but this is rarely happen.

How many textviews it is OK to create on iPhone?

I am developing non-standard rich text view to display output of some other program. I found it is very easy to do by just adding loads of UITextView into ScrollView, and then set various properties for each label. Like text size, color, transparency etc, etc. Some of them could be clickable buttons.
But now the logical question, how many TextViews iPhone can safely handle?
Of course, I can do some tests myself, (and will I do) but it might not be reliable, maybe someone knows better from experience or some documentation or calculations?
Maybe the question could be generalized to "how many views"? But I am interested mostly in TextViews so far.
I think you don't need to worry about the safe number of UITextView you can use. Because you know the screen of the iPhone is so small. Do you think you need so many UITextView on one screen that the iOS even can not handle?

MVC pattern with Views adapting to different screen resolutions

I'm starting to think about how to solve the problem of developing an app for all iOS devices with different screens (resolution, ratio, retina, etc). I'm working with Adobe Air (AS3), but that really doesn't matter because I'm in a conceptual phase and I'm concerned about the patterns to use.
If I was only developing for iPad, the problem would be as simple as doubling measures and sizes to adapto to retina and non-retina devices. But I need to take into account iPhones, iPods, and eventually Android too with it's myriad of screens.
So far I see those possible options. I'm sorry if there's already some terminology for those options, but I'll just say in it my own words.
Intelligent views that have some sort of liquid layout, and also intelligent components that adapt to the space the view is assigning to them, and to the screen dpi for font sizes, and image sizes. For example: the view says "here goes a button on the bottom with this width/height". The button already knows what font size the text must be depending on the screen dpi.
Factorization with parameters of different UI view classes. So I'd have one view class for iPad, another for iPhone, etc. and there would be one class that would factorize the instantiation of the view depending on the device. Each of those classes could be hand tailored to be completely different from each other, but the underlying model and (hopefully) the controller would be the same on every device.
A middle way approach: One UI View class for tablets, another for phones, and each of those with some sort of liquid capacity to fine tune the position and size of elements (buttons, texts, images, etc).
External config files that give the View some parameters depending on the device. That would be some sort of custom CSS.
I'm sure I'm not the first person to find this rock on my path.
So how is this problem usually solved?
Is there some stablished pattern for those scenarios?
Is there some reference (book, article) I should read?
I haven't been able to find an in depth answer to this. If it's already been asked/answered please don't downvote. Post the link in the comments and I'll just delete this question.
You are describing Responsive Web Design. There are multiple approaches and ways to make you site responsive (i.e. capable of running on multiple screen sizes without having to modify or reconfigure the codebase or rely on user-agent to detect the browser info).
Start from here: http://msdn.microsoft.com/en-us/magazine/hh653584.aspx
Also consider various open-source CSS frameworks that will simplify your life. For example, Bootstrap and HTML5 Boilerplate. Both of those are fairly independent of your development platform and should work well with MVC.

Resources