Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using HTML or any markup language for the views in iOS

Programatically implementing interfaces on iOS is too verbose in my opinion. Sure, you could do it in IB but I fancy reusing my code and I hate having to change one thing in 10 different places or spreading my interface in 100 IB files to avoid that. Also, IB is very slow, although I own a new generation Macbook Pro, I still have to wait 3-4 seconds to open large files, not to mention the lack of zoom and the general clumsiness makes me run when I hear about it.

Now, to the question at hand, is there any open source effort or otherwise a way to describe the layout (not necessarily the view "logic"), just the layout in HTML or any other markup language.

So far I've seen that CALayer has a style property that could be used, however, it doesn't support positioning. Also, I tried to use UIWebView but it seems to force me to have my logic inside HTML code as well, which I don't want to, plus, it's slower.

What else could I try?

like image 259
Meda Avatar asked Nov 03 '22 23:11

Meda


2 Answers

You could have a look at Nimbus CSS. It does exactly what you're looking for in CSS. It supports positioning and it's pretty stable.

like image 188
Rad'Val Avatar answered Nov 15 '22 10:11

Rad'Val


I realize this question is a couple of years old, but in case anyone else is looking for something similar, take a look at MarkupKit:

https://github.com/gk-brown/MarkupKit

It's an open-source framework I created that allows you to build native iOS apps in markup. For example, you can create a label instance like this:

<UILabel text="Hello, World" font="System 24" textColor="#ff0000"/>

rather than this:

UILabel *label = [UILabel new];

[label setText:@"Hello, World"];
[label setFont:[UIFont systemFontOfSize:24];
[label setTextColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0]];

It also supports dynamic localization and CSS-like styling, among other things.

Complete project documentation can be found here:

https://github.com/gk-brown/MarkupKit/blob/master/README.md

Examples and other information are available in the wiki:

https://github.com/gk-brown/MarkupKit/wiki

Hope you find it useful.

like image 33
Greg Brown Avatar answered Nov 15 '22 08:11

Greg Brown