Are there any convenient ways for managing color schemes in an iOS app? - ios

I was wondering if there are any standard or convenient ways for managing color schemes with storyboards in an iOS app, instead of having to manually change the colors of many different UI objects.
Thanks!

There is a tintColor that a few interface elements will pick up by default. You can configure the storyboard (right side menu) on the Global Tint setting.
If you want more costumization, there is a cool recent feature called UIAppearance. It lets you costumize interface elements by code, and that is applied in all such elements across the app.
Here is more info:
http://nshipster.com/uiappearance/

This is a fine question. We once had to do a complete color palette adjustment in a very large (> 100 view controller) app, and it was a suboptimal experience. For colors that are defined in code, the changes were easy enough. For colors specified in xibs or storyboards, though, it sucked. Because IB stores colors as raw double RGB values, there's no easy way to grep through the xib and storyboard xml files to do a simple search and replace. I wound up having to write a Ruby script that would find RGB values in the XML files, convert the doubles to integers in the (0..255) range, and then prompt the user to enter new values. The script cached the user's answers so that the user wasn't prompted multiple times for the same color values.
In hindsight, I still would prefer to specify colors in the storyboards & xibs so that it's as WYSIWYG as possible, and instead insist that the designers can make the changes themselves if they ever decide to modify the palette. :)

Related

how to make app with the Dynamic type support?

I have completed making an IOS app. Now its been final and was ready to upload, but suddenly I was given a task to apply a new thing in the app and that is as Under
When user increases text size From the Settings > Accessibility > Larger Text or from Settings > Display And Brightness > TextSize now my app text appearance must change accordingly.
What I want: As I told you above that app is completed, and as I have used too many UILabels, UIButtons and UITextViews, so I am finding a way to how to change their text size accordingly to newly changed text size by the user. Is it possible to add any extension that increase the text size of app in more generic way. so that I do not have to go to every view in storyboard to make the view of dynamic type.
The process of changing and converting every view or coding in every class will be cumbersome. Is there any short way to handle it while everything is already completed.
Please help thanks.
The process of changing and converting every view or coding in every class will be cumbersome. Is there any short way to handle it while everything is already completed.
I'm sorry to tell you that implementing the Dynamic Type feature in an already existing app is never easy and quick to be done.
It's like making the design, it takes time and requires conception for adapting the ergonomic a11y to provide the best user experience.
Even if many things can be done in the Interface Builder, I prefer to handle everything in code because you can mutualize many properties and methods while it's element by element in the IB.
Among other things, you'll have to:
Use the text styles and activate the adjustsFontForContentSizeCategory properties of your elements to have an automatic update of your system font size.
Listen to the traitCollectionDidChange method that belongs to the UITraitEnvironment informal protocol to be aware of the font size settings changes.
Use dynamic values for adapting all your constraints so as to reorder appropriately every single element and make the containers fit their contents according to the different font size settings.
Adapt and customize every Large Content Viewers to enlarge UI elements when the Dynamic Type can't be applied (only since iOS 13).
There's no magic trick to make an app with the Dynamic Type support: you have to know how it works and then build every element as you do in your daily programming.
Hereunder few links that may help to reach your goal:
A detailed summary of the WWDC video 'Building Apps with Dynamic Type' where every steps are explained with a complete example in the end.
Some code snippets (ObjC + Swift) and illustrations to provide explanations for code implementation.
Few outlines to have in mind when testing a Dynamic Type implementation.
All these information could help you make your app with the Dynamic Type support.

How to override values/file in framework in ios

I have developed the application in ios. It is working fine. I have converted it as a framework(library) so that My codebase remain same.
I have multiple clients for this app. So I need to change the following things
Colors (As it will change the background colors, text colors etc)
Strings (Like headings and labels in some views)
Some files like Images etc
What I want:
As I am android developer, So in that I can create another color file in my client app with same color name, that replaces the color value in Library. and this it just require only one file to be replace and it automatically overrides in library. Same was the case with the String.xml and image files
Looking for something like that as I have described above.
What I searched and found so far:
After searching alot I have found that I need to make outlets public and then I can give them color by accessing them. But What If I have a 1000 of views and 1000s of outlets to make to use this technique, Isnt it better to use it as same way as in android I described above.
Confusions:
Is there anyway in IOS to declare color in a file and to use them in IB and code as well. Well I read about Color.xcassets but that is for ios 11 I think
How to make strings file and to use them in IB and in code. Like strings.xml file in android?
So I short, I want to updated colors,Strings and file per client wise and I do not know how to do it and what is a best way of doing this??
Please help and thanks in advance. Please share your views.
You should configure your framework to read from predefined files in .plist file. this will require only changing the files content in the client application.
Easy way to handle colors and theme using SkinKit. This is too old code. You just reuse idea or create custom themes configuration file(plist,JSON),Strings and images as .bundle read all color and customization from that bundle. So easy to change Colors, Strings and Images assert for various clients.
You seem to have a misconception about what IB is — in particular, what a nib is, and what it means to edit a nib, which is what Interface Builder does. A nib is a file expressing potential instances, typically views. You edit it on your computer using Xcode (IB). When your app runs, the nib is loaded and the views are actually instantiated. That is the only thing you can do with a nib when the app runs. You cannot modify the nib in some way when the app runs; all you can do is load the nib and get the instances.
So, if you want to change all the titles of buttons or all the colors of views when your app runs in accordance with some configuration file, you can do that, but that has nothing to do with nibs or IB. You would just load the nib as usual to get the views, and then change them all, one by one, in code. You could use tags or some other identification mechanism to help you find each view, but that would be entirely up to you to work out.

it's better/faster making a view and add subviews programatically than using a storyboard [duplicate]

This question already has answers here:
Adding Views. Storyboard VS. Programmatically [closed]
(2 answers)
Closed 6 years ago.
Is it more efficient to add views and subviews programmatically than using a storyboard to add them ?
What is be the best practice ? Does the best practice depend on the situation ? If so, when is it preferable to use the one method over the other ?
Storyboard vs Code comes up an awful lot. And I think looking at it as which is better often starts flame wars. So instead I'll list out pros and cons for each, then you can hopefully make an informed decision.
This is by no means an exhaustive list. I'd love to see edits or comments adding additional bullet points.
Storyboard Pros
Storyboards are great for getting a concept working quickly.
They're great for seeing your actual app and previewing it on multiple devices.
They make it really easy to customize appearances and explore whats possible.
They're fantastic for beginners as they remove one barrier and let you focus on code for your app rather than some boiler plate UI.
Storyboard Cons
Storyboards and Xibs are not great for merging. Its possible to read the XML and make decisions about merge conflicts, but its certainly not enjoyable.
Overtime as you customize your app and build the custom parts that make it special, Storyboards can't keep up. This means that the benefit of seeing and previewing your app as you see it on device slowly loses its value as more and more of your app is done in code out of necessity.
Storyboards don't have a huge performance hit for actual users, but they definitely slow Xcode down on even the fastest machines.
You can't customize everything in Interface Builder that you can in code, so its inevitable you'll have some code and some Storyboard customization. Later when you want to change something, you'll have to check at least two places for the right place to change it.
If you're using the same fonts and colors throughout the app, its easy to change in code in one place. In Storyboard you'll need to change it for every single label or view you've set up. You can easily set fonts and colors in code while using Storyboard for the rest of your layout, but over time you'll find your storyboards represent less and less of your actual app.
While its possible to have pixel perfect designs in Storyboard, drag and drop isn't as precise as entering specific numbers. Storyboard does support entering those numbers, but you need to navigate to multiple places and if you drag it later the numbers are all reset.
Reusing views typically involves copy and pasting them. These causes issues later when you need to make changes.
Showing and hiding views at certain times is doable, but again leaves your storyboard in an unrealistic state compared to your actual app.
Programmatic Pros
All your code is in one place making it easier to debug or change later.
Subclasses and custom properties are no different from first class views and properties. Your customizations will be easy to manage.
Views that are reused throughout the app only need to be created once.
Merge conflicts are often easy to understand and make decisions.
Dependency Injection is one of the safest ways to instantiate UIViewControllers and ensure necessary information is passed in, its not possible with Storyboards leading to less straight forward and more bug prone code.
Programmatic Cons
The additional complexity can be a stumbling block for beginners.
Writing a few lines of code can take longer than clicking a few checkboxes.
When working with layouts, you'll need to visualize it in your head or run your app to see what your layout looks like as you make changes. This can be difficult or slower for some.
Storyboard exposes checkboxes and buttons for many customizable properties like background color, font, etc. This makes it easy to see at a glance what you can customize. (Though as mentioned above its not everything) In Code, you'll need to look at documentation or headers to understand what you can customize.

Change color-theme in whole iOS application

I am going to implement Alert feature in my application.
When user taps an alert button my application is about to change all orange (default) colors to red (Navigation bar, switches, Tab bar, Buttons, views and other stuff).
I want to implement it using "css" files also known as stylesheets.
I've found two libraries: Motif and NUI.
The most important problem is to dynamically change theme inside application. Motif can do this but I want to do it more simple.
Also I learned that NUI can change the app theme too but I can't to change it dynamically.
P.S. I am using storyboard and XIB-files. I need to add runtime attribute for object's key-path. This attribute will go to my stylesheet file and apply styles. It's the most simple way I think.
Can I do it simply and without any libraries?
P.S.S. NUI is more simple for me. Maybe you know how to change styles when application runs.
There are ways of making this work, but not very simply. So your options are either to construct your own solution, or use a library.
If you are looking for something that feels easier and more native than NUI or Motif, and which also lets you assign styles and see them rendered live inside your storyboards, take a look at my library for this: https://github.com/daniel-hall/Stylish
Here is a demonstration of changing the "stylesheet" (which can be created either in code, or in an external JSON file) at runtime:

Means to use Color Swatch in settings?

I'd hoped to find that someone's worked out a means to provide a choice of colors from the application settings (even with InAppSettings) with some kind of view of the (graphical) color swatch itself. My fallback implementation is a settings child pane of text multi-values of a small set of colors obviously without any swatch (unless there's a way of using icon.pngs therein).
Is someone aware such an implementation?
There is currently no approved way to do what you ask besides RGB values, and even then it's not user friendly. I can recommend two projects if you would like to provide a pallet in-app though:
IL Color Picker is simply excellent. I cannot recommend it highly enough. It's intuitive, and unique, and it looks like photoshop's implementation.
Color Picker a control styled like a nib's default color pallet.

Resources