NimbusKit
1.2.1 - Fork Nimbus on Github - Visit the Nimbus Wiki
The iOS framework that grows only as fast as its documentation
|
A leight-weight DOM-like object to which you attach views and stylesheets.
To be clear: this is not an HTML DOM, but its intent is the same. NIDOM is designed to simplify the view <=> stylesheet relationship. Add a view to the DOM and it will automatically apply any applicable styles from the attached stylesheet. If the stylesheet changes you can refresh the DOM and all registered views will be updated accordingly.
Because NimbusCSS supports positioning and sizing using percentages and relative units, the order of view registration is important. Generally, you should register superviews first, so that any size calculations on their children can occur after their own size has been determined. It's not feasible (or at least advisable) to try and untangle these dependencies automatically.
NIDOM is most useful when you create a single NIDOM per view controller.
You then register views in the DOM during loadView or viewDidLoad.
Once the view controller unloads its view you must unregister all of the views from your DOM.
Tasks | |
Dynamic View Construction | |
id | target property |
Creating NIDOMs | |
(id) | - initWithStylesheet: |
(id) | + domWithStylesheet: |
(id) | + domWithStylesheetWithPathPrefix:paths: |
(id) | + domWithStylesheet:andParentStyles: |
Registering Views | |
(void) | - registerView: |
(void) | - registerView:withCSSClass: |
(void) | - unregisterView: |
(void) | - unregisterAllViews |
Re-Applying All Styles | |
(void) | - addCssClass:toView: |
(void) | - removeCssClass:fromView: |
(void) | - refresh |
(void) | - refreshView: |
Debugging | |
(NSString *) | - descriptionForView:withName: |
(NSString *) | - descriptionForAllViews |
Using the [UIView buildSubviews:inDOM:] extension allows you to build view hierarchies from JSON (or anything able to convert to NSDictionary/NSArray of simple types) documents, mostly for prototyping.
Those documents can specify selectors, and those selectors need a target. This target property will be the target for all selectors in a given DOM. Truth is it only matters during buildSubviews, so in theory you could set and reset it across multiple build calls if you wanted to.
Initializes a newly allocated DOM with the given stylesheet.
Returns an autoreleased DOM initialized with the given stylesheet.
Returns an autoreleased DOM initialized with a nil-terminated list of file paths.
Returns an autoreleased DOM initialized with the given stylesheet and a "parent" stylesheet that runs first.
Doing this rather than compositing stylesheets can save memory and improve performance in the common case where you have a set of global styles and a bunch of view or view controller specific style sheets.
Registers the given view with the DOM.
The view's class will be used as the CSS selector when applying styles from the stylesheet.
Registers the given view with the DOM.
The view's class as well as the given CSS class string will be used as the CSS selectors when applying styles from the stylesheet.
Create an association of a view with a CSS class and apply relevant styles immediately.
Removes the association of a view with a CSS class.
Note that this doesn't "undo" the styles that the CSS class generated, it just stops applying them in the future.
Removes the given view from from the DOM.
Once a view has been removed from the DOM it will not be restyled when the DOM is refreshed.
Removes all views from from the DOM.
Reapplies the stylesheet to all views.
Since there may be positioning involved, you may need to reapply if layout or sizes change.
Reapplies the stylesheet to a single view.
Since there may be positioning involved, you may need to reapply if layout or sizes change.
Describe what would be done to view given the existing registrations for it.
In other words, you must call one of the register view variants first before asking for a description. The current implementations return actual objective-c code, using viewName as the target. This allows you to theoretically replace the CSS infrastructure with generated code, if you choose to. More importantly, it allows you to debug what's happening with view styling.
Call descriptionForView for all registered views, in the order they would be applied during refresh.