2014-02-26 19 views
1

我正在使用PixateFreestyle作爲吊艙。我可以使用default.css文件中的styleId設置樣式。我試圖在代碼中隨時更改樣式信息。我試過這個:Pixate如何在代碼中動態改變樣式? (iOS)

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

這沒有效果。我也嘗試過:

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

這也沒有效果。

這可能嗎?

回答

2

字符串中沒有大括號,而是執行此操作:

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

也有一個類別,你可以導入:

#import <PixateFreestyle/NSDictionary+PXCSSEncoding.h> 

然後你就可以使代碼吸塵器是這樣的:

self.view.styleCSS = @{ @"background-color": @"#991199", 
         @"color"   : @"red" 
         }.toCSS; 
+0

此外,你不應該需要調用[self.view updateStyles]; – pixatepaul