Development

Modern iOS app development part 1

iOS is a great app development platform, yet its UI programming model is so 1990s, the UI library is not so productive compared to the html CSS model. After iOS5, UIAppearance did improve such an outdated model and it allows you to modularize UI themes like the follow code:

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
       setTintColor:myNavBarColor];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], [UIPopoverController class], nil]
        setTintColor:myPopoverNavBarColor];
[[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], nil]
        setTintColor:myToolbarColor];
[[UIBarButtonItem appearanceWhenContainedIn:[UIToolbar class], [UIPopoverController class], nil]
        setTintColor:myPopoverToolbarColor];

But I would say why stop there? Why don’t we use CSS to stylize our iOS apps? And Pixate took a bold step towards that direction! You no longer need to use Objective-C code to set the themes:

#top-slider max-track {
  background-color: rgba(192, 192, 192, 0.5);
  background-size: 10px 10px;
  background-inset: 0px 5px;
  border-radius: 3px;
}

navigation-bar {
    color: white;
    background-color: #288de3;
}

tab-bar {
    color: #288de3;
    selected-color: white;
    background-color: #288de3;
}

tab-bar-item {
    color: white;
    font-family: "Open Sans";
    font-weight: semibold;
    font-size: 12;
}

Want to support both iPhone and iPad? No problem, use the @media rule:

/* Rule sets apply only when the device is in portrait orientation */
@media (orientation:portrait) { }

/* Rule sets apply if the device's height (ignores orientation)
 is at least 1000 pixels and if the device has a retina display. */
@media (min-device-height:1000px) and (scale:2) { }

/* Apply rules to iPad Mini in landscape mode. */ 
@media (orientation:landscape) and (device:ipad-mini) { }

Imagine how many lines of code can be reduced by using such a great library! How about readability and modularization?

It’s unlikely that we are going to reinvent iOS programming, but I believe by using the correct programming model, we can reduce the code size of a iOS app by the factor of 10.

About the Author

More from this Author

Thoughts on “Modern iOS app development part 1”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up
Categories