gpt4 book ai didi

ios - Pixate 如何在代码中动态更改样式? (iOS)

转载 作者:行者123 更新时间:2023-11-29 10:47:02 25 4
gpt4 key购买 nike

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com