Frage

Is there a way to get values from Pixate programmatically? I'd like to be able to get a CSS value for a specific id, class, or element.

War es hilfreich?

Lösung

Here's an example on how to get a view tint color. Any property name will work instead of course.

PXStylesheet *currentSheet = [PixateFreestyle currentApplicationStylesheet];
PXRuleSet *rules           = [currentSheet ruleSetsMatchingStyleable:view][0];
PXDeclaration * decl       = [rules declarationForName:@"-ios-tint-color"];
UIColor *color             = decl.colorValue;

A few things to note,

  • You can have more than 1 style sheet. User, view, and application. Use [PXRuleSet ruleSetWithMergedRuleSets:rules] if this is the case

  • ruleSetsMatchingStyleable: is a private call. You need to include PXStylesheet-Private.h

  • In my example I only had 1 rule set. You may have more so you probably want to iterate the response of ruleSetsMatchingStyleable: .

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top