• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

alibaba/VirtualView-iOS: A solution to create & release UI component dynamic ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

alibaba/VirtualView-iOS

开源软件地址:

https://github.com/alibaba/VirtualView-iOS

开源编程语言:

Objective-C 99.1%

开源软件介绍:

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap