I want to do another target of my IOS app by changing colors and texts to rebranding by reusing the same storyboards and swift code, but in storyboards colors and texts are hard coded so that I am able to effectively and it is confusing to to do,Can you please suggest the better approach to do this white labeling or rebranding of IOS Application.
You can either use runtime attributes, or, you can have outlets for the specific UI elements and set the color programmatically.
Its better to use coloring logic to be given via code.
and you can create category class for each target so that you can specifie the color you need for each target.
I'm developing an iOS application, and I would like to use a similar layout used in iOS settings, but I'm not sure if there is any predefined components to use, or if there's some predefined layout which does exactly what I want to achieve. It looks like this:
(source: iphonehacks.com)
I'm looking for the 'Behavior' header, the white elements like 'Animate Icon'. Do I have to create them from scratch using labels, textfields and so on, or are there any predefined components available?
Many thanks!
Appears to be a UITableView using the grouped style, and the string 'Behavior' was returned from the tableView:titleForHeaderInSection: datasource method, which is defined in the UITableViewDataSource protocol.
You can select the grouped style in storyboard by selecting the table view and changing the style with the Attributes inspector.
Does anyone know a good way of styling buttons, labels and other views but doing so like CSS and HTML (two separate files)? I suppose styling in each View Controller is not the best way, because if I have a button that is used in various View Controllers but have the same style in all of them, it'd be pretty hard to change this button's style (we would have to change code in each View Controller that uses it - that's far from maintainable). Any ideas? Perhaps put in a XML or in App Delegate?
You can use UIAppearance proxy to customize the look of all instances of your views at once.
http://nshipster.com/uiappearance/
I have a question that why should we create a class derived from UIView when I can put as many UIViews in any view controller and can access them with IBOutlet.
Is there any special functionality which we get after subclassing UIView.
May be its not a valid question, But I seriously wish to know the answer.
Any help will be appreciated.
Thanks In Advance.
example:
#Interface CustomView: UIView
{
}
Mostly you subclass UIView or any UIComponent for customization. When you subclass you can override drawRect method and do your own customization.
See the best practices for subclassing UIView here.
It simply depends! What if I want to draw some custom shape on my view? I can just subclass a UIView and use drawRect: make whatever I want and then use it. So, the reasons are numerous but really depends on your desire.
To support further. Refer the below link:
https://softwareengineering.stackexchange.com/questions/209576/what-are-the-reasons-to-create-uiview-subclass
Subclass is required only when you need to add some extra properties, behaviors, like the view should have some glossy effect, round rect corner etc.
However from UIView or from any other Cocoa Classes (foundation or UIKit or any other kit) they give you most of the required-common features, but at times as per your requirement you need to put something extra. For this purpose you extent the class by
Subclassing or Inheritance.
Class Extension.
Categories.
Custom views is easier to reuse. You can incapsulate some logic inside view (drawing logic for example) and then reuse this view.
In my current projects book pages are shown in several places. So it is very convenient to incapsulate page-presentation/drawing in one UIView.
There are several use cases that can be applied to UIView inheritance, such as:
implementing a custom control
extending UIView with methods that implement specific functionalities (although it can also be done by using a category, although that works in a different way and usually applies to different use cases)
group correlated views into a single view, to improve usage, expose a clean interface and deal with views management internally
create a base view that you want to reuse in other UIView inherited classes, without having to implement the custom look and/or behavior on each subclass
Below some examples
Custom control - You want to implement a 4 states flat push button, which 'advances' to the next state on every tap. Each state is visually represented in a different way, for instance by changing the label, the border, and/or the color. Note: in this example it would be better to extend the UIControl or UIButton, which are both subclasses of UIView
Extension - You want a view that has a rounded border, a title and a body section, with the title having a bigger font and on inverted colors (white text on dark gray background).
Grouping - You have a panel where you want to display a user profile, with several labels and values (i.e. User Name: myusername), a profile picture, dynamically laid out.
Base Class - you have a set of views that share a common look, with a rounded border, a title at top right overlapping the border, and an internal panel where to lay out content. You create a UIView subclass called SOMyPanelBaseView, and then inherit other classes from it, automatically inheriting the look
In many cases (but not all) you can skip inheritance and implement everything in a view controller, but besides being a not good object oriented design (the view is highly tied to the view controller), it makes the view controller over complicated. By inheriting from a UIView instead you implement the view functionalities in a separate class, and plug those functionalities into the view controller.
Also, an UIView inherited class can be reused - whereas if you implement everything in the view controller, you can't unless you copy and paste code around.
To sum up, I think your question can be generalized as: why should I use inheritance in object oriented programming?
The same reasons behind using inheritance in OOP is the same as using it in a specific case, in our case for UIView. The topic is described pretty well on wikipedia
Is there an easy way to a Settings.bundle style form in an app? I have seen InAppSettingsKit, but I just want to create a form for data entry that has some nested pickers and other features simple to implement with Settings.bundle.
It is very easy to achieve, the settings screens are simply grouped table views with the standard styling.
With storyboards, the "static" content feature makes it even easier - this mode allows you to specify the contents of each cell right there in the storyboard, you don't need any datasource methods and can do it all via outlets. There is a good tutorial on Ray Wenederlich here