我将PixateFreestyle用作广告连播。我可以使用default.css文件中的styleId设置视图样式。我试图在代码中动态更改样式信息。我已经试过了:
self.view.styleCSS = [NSString stringWithFormat:@"{ background-color : #991199; }"];
[PixateFreestyle updateStylesForAllViews];
这没有作用。我也尝试过:
self.view.styleCSS = [NSString stringWithFormat:@"{ background-color : #991199; }"];
[self.view updateStyles];
这也没有效果。
这可能吗?
最佳答案
字符串中没有大括号,请执行以下操作:
self.view.styleCSS = @"background-color: #991199;";
您还可以导入一个类别:
#import <PixateFreestyle/NSDictionary+PXCSSEncoding.h>
然后,您可以使用以下代码使代码更简洁:
self.view.styleCSS = @{ @"background-color": @"#991199",
@"color" : @"red"
}.toCSS;
关于ios - Pixate如何在代码中动态更改样式? (iOS),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22030284/