3

有没有办法以编程方式从 Pixate 获取值?我希望能够获得特定 id、类或元素的 CSS 值。

4

1 回答 1

2

这是有关如何获取视图色调颜色的示例。当然,任何属性名称都可以使用。

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

有几点要注意,

  • 您可以拥有超过 1 个样式表。用户、视图和应用程序。如果是这种情况,请使用 [PXRuleSet ruleSetWithMergedRuleSets:rules]

  • ruleSetsMatchingStyleable:是私人电话。您需要包含 PXStylesheet-Private.h

  • 在我的示例中,我只有 1 个规则集。你可能有更多,所以你可能想要迭代 ruleSetsMatchingStyleable: 的响应。

于 2014-07-22T22:32:44.427 回答