alibaba/VirtualView-iOS

Name: VirtualView-iOS

Owner: Alibaba

Description: A solution to create & release UI component dynamically.

Created: 2017-12-07 00:24:12.0

Updated: 2018-05-18 16:57:16.0

Pushed: 2018-04-23 06:54:21.0

Homepage:

Size: 1545

Language: Objective-C

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

CocoaPods CocoaPods CocoaPods

VirtualView

A solution to create & release UI component dynamically.

It a part of our Tangram solution. And it can be used as a standalone library.

???????????? UI ??????

???? Tangram ??????????????????

?????VirtualView iOS

?????VirtualView?????VirtualView iOS??

Features

feature

  1. Write component via XML.
  2. Compile XML to a .out (binary) file.
  3. Load .out file in iOS application.
  4. Create component from loaded template and bind data to it.
  5. Show the component.

????????? XML ?????????????????? .out ?????????? VirtualView ? App ????? .out ??????????????????? UIView ?????????

Install
CocoaPods

Use VirtualView alone:

pod 'VirtualView'

Use VirtualView with Tangram:

pod 'Tangram'

CocoaPods will install VirtualView as a part of Tangram 2.x.

Source codes

Or you can download source codes from releases page and put them into your project.

How to use
  1. Load component template from .out file.
![[VVTemplateManager sharedManager].loadedTypes containsObject:@"icon_type"]) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"icon_file" ofType:@"out"];
[[VVTemplateManager sharedManager] loadTemplateFile:path forType:@"type_alias"];

  1. Create component.
.viewContainer = [VVViewContainer viewContainerWithTemplateType:@"icon_type"];
f.view addSubview:self.viewContainer];
  1. Bind data and calc the layout (fixed size).
.viewContainer.frame = CGRectMake(0, 0, SCREEN_WIDTH, 1000);
f.viewContainer update:@{
@"type" : @"icon-type",
@"imgUrl" : @"https://test.com/test.png"

  1. If you want to clac size.
f.viewContainer updateData:@{
@"type" : @"icon-type",
@"imgUrl" : @"https://test.com/test.png"

ze size = CGSizeMake(MAX_WIDTH, MAX_HEIGHT);
 = [self.viewContainer estimatedSize:size];
.viewContainer.frame = CGRectMake(0, 0, size.width, size.height);
f.viewContainer updateLayout];

See more details in the demo project.

XML Compile Tools

An executable jar (need Java 1.8) is in the CompileTool path. In the demo project, we use bash script to sync XML template changes. You can find the script here:

compile_tools_script

See more details here.

???

?? tangram_ ??????????? Tangram ??????????????


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.