ExtFastUI 0.0.1

ExtFastUI 0.0.1

pn-x维护。



ExtFastUI 0.0.1

  • 作者
  • pn-x

ExtFastUI

快速构建用户界面

安装

将以下行添加到您的 Podfile 中

pod 'ExtFastUI'

为什么使用 ExtFastUI?

创建视图代码冗长

@interface ViewController ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *badgeImageView;
@property (nonatomic, strong) UILabel *firstContentLabel;
@property (nonatomic, strong) UILabel *secondContentLabel;
@property (nonatomic, strong) UILabel *thirdContentLabel;
@property (nonatomic, strong) UILabel *fourthContentLabel;
@property (nonatomic, strong) UILabel *fifthContentLabel;
@property (nonatomic, strong) UIButton *doneButton;

@end
  
@implementation ViewController

- (void)viewDidLoad {
	self.titleLabel = [UILabel new];
  self.badgeImageView = [UIImageView new];
  self.firstContentLabel = [UILabel new];
	self.secondContentLabel = [UILabel new];
	self.thirdContentLabel = [UILabel new];
	self.fourthContentLabel = [UILabel new];
	self.fifthContentLabel = [UILabel new];  
	self.doneButton = [UIButton new];
  
  self.fifthContentLabel.userInteractionEnabled = YES;
  UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
	[self.fifthContentLabel  addGestureRecognizer:tap];
  
	[self.view addSubview:self.titleLabel];
  [self.titleLabel addSubview:self.badgeImageView];
  [self.view addSubview:self.firstContentLabel];
  [self.view addSubview:self.secondContentLabel];
  [self.view addSubview:self.thirdContentLabel];
  [self.view addSubview:self.fourthContentLabel];
  [self.view addSubview:self.fifthContentLabel];
  [self.view addSubview:self.doneButton];
}

@end

现在您可以编写如下代码

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self ext_remountTemplate];
}

- (NSArray *)ext_template:(nullable id)params {
    return @[
        UILabel.extViewNode(this.nodeId = @"title").append(@[
          UIImageView.extViewNode(this.nodeId = @"badge"),
        ]),
        UILabel.extViewNode(this.nodeId = @"first"),
        UILabel.extViewNode(this.nodeId = @"second"),
        UILabel.extViewNode(this.nodeId = @"third"),
        UILabel.extViewNode(this.nodeId = @"fourth"),
        UILabel.extViewNode(this.nodeId = @"fifth"; this.event.onTap = @selector(tap:)),
        UIButton.extViewNode(this.nodeId = @"done")
    ];
}

@end

高级用法

您可以在 Wiki 中找到它

许可证

ExtFastUI 采用 MIT 许可证发布