S
S
Sergey Sulakov2016-05-09 14:39:25
iOS
Sergey Sulakov, 2016-05-09 14:39:25

General view settings in iOS app?

There are for example 10 windows in the application. Everywhere set the same background, font size and the like. If you need to increase the font or replace the background, will you have to make changes in all ten windows, or can these settings be moved to a separate file, and then connected everywhere?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Petrushka, 2016-05-09
@petruska

Make a separate class of type Constants
and write methods in it that return color, font, etc.

M
ManWithBear, 2016-05-09
@ManWithBear

Make your extensions for static things and enjoy life :)

extension UIColor {
    class func ptm_black() -> UIColor {
        return UIColor ( red: 0.0895, green: 0.0895, blue: 0.0895, alpha: 1.0 )
    }
    class func ptm_grey() -> UIColor {
        return UIColor ( red: 0.8115, green: 0.8115, blue: 0.8115, alpha: 1.0 )
    }
    class func ptm_brown() -> UIColor {
        return UIColor ( red: 0.4042, green: 0.2848, blue: 0.2091, alpha: 1.0 )
    }
    class func ptm_green() -> UIColor {
        return UIColor ( red: 0.3137, green: 0.6824, blue: 0.3333, alpha: 1.0 )
    }
    class func ptm_red() -> UIColor {
        return UIColor ( red: 0.9381, green: 0.1339, blue: 0.1453, alpha: 1.0 )
    }
    class func ptm_gold() -> UIColor {
        return UIColor ( red: 0.9457, green: 0.7034, blue: 0.0621, alpha: 1.0 )
    }
}

I
Ivan Vorobei, 2016-05-09
@ivanvorobei

That's right : take out the settings separately.
Avoid code/action duplication.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question