Skip to content

Tutorial 1: Create View Controller with xml layout

zhenglibao edited this page Jan 13, 2018 · 1 revision

Derive HelloWordVC from FlexBaseVC

@interface HelloWordVC : FlexBaseVC

@end

@implementation HelloWordVC

- (void)viewDidLoad {
    [super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end

Notice: you need to write nothing. Just derive it from FlexBaseVC will work.

Write your layout file with name 'HelloWordVC.xml'

The name 'HelloWordVC' is not necessary, but it will simplify to init the view controller.

This file looks:

<?xml version="1.0" encoding="utf-8"?>
<UIView layout="flex:1,justifyContent:center,alignItems:center" attr="bgColor:white">
    <UILabel attr="fontSize:16,color:#333333,text:helloWord"/>
</UIView>

Use this view controller as normal

HelloWordVC* vc = [[HelloWord alloc]init];
[navigationController pushViewController:vc animated:YES];

Build & run it.

Clone this wiki locally