Giter Site home page Giter Site logo

kinglions / virtualview-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alibaba/virtualview-ios

0.0 2.0 0.0 1.51 MB

A solution to create & release UI component dynamically.

License: MIT License

Shell 0.12% Ruby 0.39% Objective-C 99.05% Python 0.44%

virtualview-ios's Introduction

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.
if (![[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.
self.viewContainer = [VVViewContainer viewContainerWithTemplateType:@"icon_type"];
[self.view addSubview:self.viewContainer];
  1. Bind data and calc the layout (fixed size).
self.viewContainer.frame = CGRectMake(0, 0, SCREEN_WIDTH, 1000);
[self.viewContainer update:@{
    @"type" : @"icon-type",
    @"imgUrl" : @"https://test.com/test.png"
}];
  1. If you want to clac size.
[self.viewContainer updateData:@{
    @"type" : @"icon-type",
    @"imgUrl" : @"https://test.com/test.png"
}];
CGSize size = CGSizeMake(MAX_WIDTH, MAX_HEIGHT);
size = [self.viewContainer estimatedSize:size];
self.viewContainer.frame = CGRectMake(0, 0, size.width, size.height);
[self.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 为好友,以便我们邀请你入群。

virtualview-ios's People

Contributors

harrisonxi avatar longerian avatar isaced avatar

Watchers

James Cloos avatar Frank avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.