-
Notifications
You must be signed in to change notification settings - Fork 257
使用样式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标签中的样式同时支持布局属性和视图属性
Flexbox Introduction & performance (in Chinese)
Tutorial 1: Create View Controller with xml layout
Tutorial 2: Create Table Cell with xml layout
Tutorial 3: Embed xml layout into traditional view hierarchy
Tutorial 4: Use custom view in xml layout
Tutorial 5: Create reusable view using xml layout file