Skip to content

Comment on Show HN: FlatUIKit - Flat UI components for iOSparent

Comments

Thanks for sharing. Can you talk a bit about your decision to lean on categories so much? I'd personally prefer to see a few more base clases and DRY it up a bit. EDIT: And maybe everything inside a single header to include?

Great question. For classes with sufficiently rich customization options (UISlider, UIStepper, UIBarButtonItem, etc) I don't think it's necessary to provide a full-on subclass, as ultimately I'm not really changing what the class does. I'm really just providing a mixin for a particular set of UI customizations (setting colors, etc), which categories are perfect for.

Some classes (UIAlertView and UISwitch, most particularly) aren't very flexible in terms of appearance customization, so I had to reimplement them to achieve desired effects. Using them is more difficult: to use an FUISwitch (my UISwitch clone) you have to replace any UISwitches in your app with FUISwitches (also, if you were using categories/subclasses of UISwitch to do some custom stuff, they would break).

Moving logic to a base class isn't really possible, as most of those classes already inherit from UIControl (and I'm not crazy/motivated enough to reimplement them all from scratch - UIKit is awesome, and I want to lean on it as much as possible).

The single header totally makes sense, I'll be sure to add that.

TL;DR: UIKit is great, I don't want to reinvent the wheel, categories are really easy to integrate into existing projects.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.