Skip to main content

tool.lua

所有支持的ui都封装在这个文件中,可以直接调用

支持的ui类型

目前支持以下几种UI

  UI_TYPE_TEXT              = 0; // 文本
UI_SIGNAL_PROCESS_CIRCLE = 1; // 单进度,圆
UI_SIGNAL_PROCESS_LINE = 2; // 单进度,线
UI_LINE_CHART = 3; // 折线图
UI_ICON_BUTTON = 4; // 点击图标
UI_MARKDOWN = 5; // markdown

UI的共同能力

函数名功能参数返回值
SetDetail(detail)设置详情,点击会展示detail 字符串 markdown格式内容UI
SetHeight(height)设置高度height number 高度UI
AddAction(action)添加菜单action Action 动作UI

基础的组件


String 字符串

函数名功能参数返回值
NewString(str)创建字符串str 字符串 字符串内容String
SetContent(content)设置内容content 字符串 字符串内容String
SetColor(color)设置颜色color 字符串 颜色String
SetBackendColor(color)设置背景颜色,设置后会变成标签样式color 字符串 颜色String
SetBackendColor(color)设置背景颜色,设置后会变成标签样式color 字符串 颜色String
SetOpacity(opacity)设置背景透明度opacity number 透明度0-1String
SetFontSize(size)设置字体大小size number 字体大小String

Text 多段文本

文本有多个位置可以布局,比如下面,每一个位置都可以放一个String

0_00_10_2
1_01_11_2
函数名功能参数返回值
NewText(alignment)创建文本alignment 字符串 对齐方式 leading 左,center 中,trailing 右Text
SetString(row, col, str)设置某个位置的字符串row number
col number
str String 字符串(非原生字符串)
Text
AddString(row, str)在某一行添加字符串row number
str String 字符串(非原生字符串)
Text
SetAlignment(a)设置对齐方式a 字符串 对齐方式 leading 左,center 中,trailing 右)Text

Point 点

折线图上点的定义

函数名功能参数返回值
NewPoint(val, x)创建一个点val number 数值
x 字符串 横坐标
Point
SetVal(val)设置数值val number 数值Point
SetX(x)设置横坐标x 字符串 横坐标Point

Input 用户输入

函数名功能参数返回值
NewInput(desc, priority)创建用户的输入desc 字符串 描述
priority number 优先级
Input
SetVal(val)设置默认值val 字符串Input

Action 动作

UI的菜单点击事件

函数名功能参数返回值
NewAction(func, arg, name)创建一个点击动作func 字符串 回调服务端的函数名
arg table 需要透传给服务端的参数
name 字符串 动作展示的名字
Action
SetName(name)设置名字name 字符串 显示的名字Action
SetCheck(check)设置二次确认check bool 是否需要二次确认Action
SetIcon(icon)设置图标icon 字符串 图标,IOS支持的所有原生图标Action
SetFunc(func)设置回调函数名func 字符串 函数名Action
SetArg(arg)设置回调函数时需要透传给服务端的参数arg table 参数Action
AddInput(key, input)添加用户输入key 字符串 用户输入的参数名
input Input 用户输入
Action

ProcessData 进度数据

函数名功能参数返回值
NewProcessData(cur, total)创建一个进度数据cur number 当前数值
total number 总数
ProcessData

IconButton 点击图标

函数名功能参数返回值
NewIconButton()创建一个可点击的带icon的buttonIconButton
SetIcon(icon)设置icon名字icon 字符串 IOS系统自带的所有iconIconButton
SetColor(color)设置icon的颜色color 字符串 如:#FFFIconButton
SetSize(size)设置icon的大小size number 字体大小IconButton
SetDesc(desc)设置展示的文本desc Text 文本IconButton
SetAction(action)设置点击的动作action Action 动作IconButton
SetId(id)设置id,唯一就行id 字符串 idIconButton