Skip to content

使用样式class

zhenglibao edited this page Oct 26, 2020 · 3 revisions

从2.8.0版本开始,每个视图元素均支持class标签,如下:

<UIView name="containerView" class="button" layout="flex:1,paddingHorizontal:20" attr="">

其中button是在全局样式表中定义的文件,格式如下: system.style

<?xml version="1.0" encoding="utf-8"?>

<styles>
    <style name="button">
        <attr name="bgColor">#333333</attr>
        <attr name="cornerRadius">8</attr>
    </style>
</styles>

最后需要在程序初始化的地方加载全局样式表,如下:

    NSString* path = [[NSBundle mainBundle]pathForResource:@"system" ofType:@"style"];
    [[FlexStyleMgr instance]loadClassStyle:path];

class标签中的样式同时支持布局属性和视图属性

Clone this wiki locally