1

我使用 PixateFreestyle 作为 pod。我可以使用 default.css 文件中的 styleId 设置视图样式。我正在尝试在代码中动态更改样式信息。我试过这个:

self.view.styleCSS = [NSString stringWithFormat:@"{ background-color : #991199; }"];
[PixateFreestyle updateStylesForAllViews];

这没有效果。我也试过:

self.view.styleCSS = [NSString stringWithFormat:@"{ background-color : #991199; }"];
[self.view updateStyles];

这也没有效果。

这可能吗?

4

1 回答 1

2

字符串中没有花括号,请改为:

self.view.styleCSS = @"background-color: #991199;";

您还可以导入一个类别:

#import <PixateFreestyle/NSDictionary+PXCSSEncoding.h>

然后你可以用这样的东西使代码更干净:

 self.view.styleCSS = @{ @"background-color": @"#991199",
                         @"color"           : @"red"
                       }.toCSS;
于 2014-02-26T02:51:37.747 回答