Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

effective UI styling for iOS app [closed]

My question is a simple one. In android, we can separate xml stylesheet from layout so that it can be reuse everywhere and edited easily for UI design change.

Is it also possible in iOS xcode? if can how (prefer if not from controller)? need libraries? what are good libraries for that?

Thank you for your answer.

like image 835
Zoedia Avatar asked Feb 19 '16 09:02

Zoedia


People also ask

Why is iOS UI better than Android?

Hipmunk UI/UX designer and iOS developer Danilo Campos explains it succinctly: "The very simple short answer is it's easier to make a good-looking, attractive iOS app compared to making an Android app." Design is built into Apple's DNA. Google's legacy, on the other hand, is search.


1 Answers

You could create your own styles using enums. By placing enums inside the Styles enum you get a nice grouping:

enum Styles {
    enum Labels {
        case Standard
        case LargeText

        func style(label: UILabel) {
            switch self {
            case .Standard:
                label.font = UIFont.systemFontOfSize(12)
            case .LargeText:
                label.font = UIFont.systemFontOfSize(18)
            }
        }
    }

    enum Buttons {
        case RedButton

        func style(button: UIButton) {
            switch self {
            case .RedButton:
                button.setTitleColor(UIColor.redColor(), forState: UIControlState.Normal)
            }
        }
    }
}

Then you can use it like this:

Styles.Labels.Standard.style(yourLabel)

You can also then make extensions for the styles you have setup:

extension UILabel {
    func style(style: Styles.Labels) {
        style.style(self)
    }
}

extension UIButton {
    func style(style: Styles.Buttons) {
        style.style(self)
    }
}

And then use the extensions like this:

yourLabel.style(.Standard)
yourButton.style(.RedButton)
like image 65
totiDev Avatar answered Oct 03 '22 00:10

totiDev