B2B网络软件

标题: AIWROK苹果部分功能UI-水平容器[Horizontal]方法小结 [打印本页]

作者: YYPOST群发软件    时间: 13 小时前
标题: AIWROK苹果部分功能UI-水平容器[Horizontal]方法小结
AIWROK苹果部分功能UI-水平容器[Horizontal]方法小结
AIWROK苹果部分功能UI-水平容器[Horizontal]方法小结 B2B网络软件
  1. //🍎UI-水平容器[Horizontal]方法小结,交流QQ群711841924

  2. //第一个方法:📌addView添加子控件

  3. var h = new Horizontal();
  4. var btn = new Button();
  5. h.addView(btn);




  6. //第二个方法:📌removeView移除视图


  7. var h = new Horizontal();
  8. h.removeView(0); // 移除第一个子控件



  9. //第三个方法:📌clearAllViews清空所有视图


  10. var h = new Horizontal();
  11. h.clearAllViews(); // 清空所有控件




  12. //第四个方法:📌getViewCount 获取视图数量

  13. var h = new Horizontal();
  14. int count = h.getViewCount(); // 获取子控件的数量




  15. //第五个方法:📌setSpacing设置控件间距


  16. var h = new Horizontal();
  17. h.setSpacing(10); // 设置控件间距为10




  18. //第六个方法:📌setBackgroundColor设置背景颜色

  19. var h = new Horizontal();
  20. h.setBackgroundColor(50,100, 150); // 设置背景颜色为红色




  21. //第七个方法:📌setAlignment 设置对齐方式


  22. var h = new Horizontal();
  23. h.setAlignment("center"); // 设置对齐方式为居中
  24. /*
  25. 可选值如下:
  26. - fill: 填充对齐
  27. - left: 左对齐
  28. - right: 右对齐
  29. - top: 顶部对齐
  30. - bottom: 底部对齐
  31. - center: 居中对齐
  32. 默认值为 fill。
  33. */
复制代码
📌addView添加子控件
类别
详情说明
方法功能
向容器中添加一个子控件,多个控件会排列到一行当中
方法签名
Void addView(Object view)
返回值
Void
参数
- Object view
:要添加的子控件对象
案例
var h = new Horizontal();
var btn = new Button();
h.addView(btn);
📌removeView移除视图
类别
详情说明
方法功能
根据指定索引移除容器中的子控件
方法签名
Void removeView(Int32 index)
返回值
Void
参数
- Int32 index
:要移除的子控件的索引(从 0 开始计数)
案例
var h = new Horizontal();
h.removeView(0); // 移除第一个子控件
📌clearAllViews清空所有视图
类别
详情说明
方法功能
移除容器中的所有子控件
方法签名
Void clearAllViews()
返回值
Void
参数
案例
var h = new Horizontal();
h.clearAllViews(); // 清空所有控件
📌getViewCount 获取视图数量
类别
详情说明
方法功能
返回当前容器中的视图数量
方法签名
Int32 getViewCount()
返回值
Int32
参数
案例
var h = new Horizontal();
int count = h.getViewCount(); // 获取子控件的数量
📌setSpacing设置控件间距
类别
详情说明
方法功能
设置子控件之间的间距
方法签名
Void setSpacing(Int32 spacing)
返回值
Void
参数
- Int32 spacing
:要设置的子控件间距值
案例
var h = new Horizontal();
h.setSpacing(10); // 设置控件间距为10
📌setBackgroundColor设置背景颜色
类别
详情说明
方法功能
根据提供的 RGB 值设置容器的背景颜色
方法签名
Void setBackgroundColor(Int32 red, Int32 green, Int32 blue)
返回值
Void
参数
- Int32 red
:红色分量(通常取值范围 0~255

- Int32 green
:绿色分量(通常取值范围 0~255

- Int32 blue
:蓝色分量(通常取值范围 0~255
案例
var h = new Horizontal();
h.setBackgroundColor(50,100, 150); // 设置背景颜色为红色
📌setAlignment 设置对齐方式
类别
详情说明
方法功能
设置容器内控件的对齐方式
方法签名
Void setAlignment(String alignment)
返回值
Void
参数
-String alignment
:对齐方式,可选值: -fill
:填充对齐 -left
:左对齐 -right
:右对齐 -top
:顶部对齐 -bottom
:底部对齐 -center
:居中对齐 默认值为fill
案例
var h = new Horizontal();
h.setAlignment("center"); // 设置对齐方式为居中
/*
可选值如下:
- fill: 填充对齐
- left: 左对齐
- right: 右对齐
- top: 顶部对齐
- bottom: 底部对齐
- center: 居中对齐
默认值为 fill。
*/
示例子 1 风格:
  1. // 🔨UI-水平容器[Horizontal]方法完整示例
  2. // 🍎UI-水平容器[Horizontal]方法小结,交流QQ群711841924

  3. printl("=== Horizontal控件方法完整示例 ===");

  4. var vc = new IOSView();
  5. vc.show(() => {
  6.     printl("Horizontal示例界面已加载");
  7.    
  8.     // 获取当前视图
  9.     var view = vc.getView();
  10.    
  11.     // 创建主容器
  12.     var mainContainer = new Vertical();
  13.     mainContainer.setSpacing(15);
  14.     mainContainer.setBackgroundColor(245, 245, 245);
  15.    
  16.     // 标题区域
  17.     var titleContainer = new Vertical();
  18.     titleContainer.setAlignment("center");
  19.     titleContainer.setSpacing(5);
  20.     titleContainer.setBackgroundColor(0, 122, 255);
  21.    
  22.     var titleLabel = new Label();
  23.     titleLabel.setText("🔨 Horizontal控件演示");
  24.     titleLabel.setFontSize(20.0);
  25.     titleLabel.setTextColor(255, 255, 255);
  26.     titleLabel.setTextAlignment("center");
  27.    
  28.     titleContainer.addView(titleLabel);
  29.     mainContainer.addView(titleContainer);
  30.    
  31.     // Horizontal方法演示区域
  32.     var demoContainer = new Vertical();
  33.     demoContainer.setBackgroundColor(255, 255, 255);
  34.     demoContainer.setSpacing(15);
  35.    
  36.     var demoTitle = new Label();
  37.     demoTitle.setText("Horizontal控件功能演示");
  38.     demoTitle.setFontSize(16.0);
  39.     demoTitle.setTextColor(0, 0, 0);
  40.     demoTitle.setTextAlignment("center");
  41.     demoContainer.addView(demoTitle);
  42.    
  43.     // 第一个方法:addView添加子控件
  44.     var addViewDemo = new Vertical();
  45.     addViewDemo.setSpacing(5);
  46.    
  47.     var addViewLabel = new Label();
  48.     addViewLabel.setText("📌 addView添加子控件");
  49.     addViewLabel.setFontSize(14.0);
  50.     addViewLabel.setTextColor(0, 122, 255);
  51.     addViewDemo.addView(addViewLabel);
  52.    
  53.     var h1 = new Horizontal();
  54.     h1.setSpacing(10);
  55.     h1.setBackgroundColor(240, 240, 240);
  56.    
  57.     var btn1 = new Button();
  58.     btn1.setText("按钮1");
  59.     btn1.setColor(0, 122, 255);
  60.     btn1.setTextColor(255, 255, 255);
  61.     btn1.setWidth(80);
  62.     btn1.setHeight(40);
  63.    
  64.     var btn2 = new Button();
  65.     btn2.setText("按钮2");
  66.     btn2.setColor(52, 199, 89);
  67.     btn2.setTextColor(255, 255, 255);
  68.     btn2.setWidth(80);
  69.     btn2.setHeight(40);
  70.    
  71.     var btn3 = new Button();
  72.     btn3.setText("按钮3");
  73.     btn3.setColor(255, 149, 0);
  74.     btn3.setTextColor(255, 255, 255);
  75.     btn3.setWidth(80);
  76.     btn3.setHeight(40);
  77.    
  78.     // 第一个方法:addView添加子控件
  79.     h1.addView(btn1);
  80.     h1.addView(btn2);
  81.     h1.addView(btn3);
  82.    
  83.     addViewDemo.addView(h1);
  84.     demoContainer.addView(addViewDemo);
  85.    
  86.     // 第二个方法:removeView移除视图
  87.     var removeViewDemo = new Vertical();
  88.     removeViewDemo.setSpacing(5);
  89.    
  90.     var removeViewLabel = new Label();
  91.     removeViewLabel.setText("📌 removeView移除视图");
  92.     removeViewLabel.setFontSize(14.0);
  93.     removeViewLabel.setTextColor(0, 122, 255);
  94.     removeViewDemo.addView(removeViewLabel);
  95.    
  96.     var h2 = new Horizontal();
  97.     h2.setSpacing(10);
  98.     h2.setBackgroundColor(240, 240, 240);
  99.    
  100.     var removeBtn1 = new Button();
  101.     removeBtn1.setText("A");
  102.     removeBtn1.setColor(0, 122, 255);
  103.     removeBtn1.setTextColor(255, 255, 255);
  104.     removeBtn1.setWidth(60);
  105.     removeBtn1.setHeight(40);
  106.    
  107.     var removeBtn2 = new Button();
  108.     removeBtn2.setText("B");
  109.     removeBtn2.setColor(52, 199, 89);
  110.     removeBtn2.setTextColor(255, 255, 255);
  111.     removeBtn2.setWidth(60);
  112.     removeBtn2.setHeight(40);
  113.    
  114.     var removeBtn3 = new Button();
  115.     removeBtn3.setText("C");
  116.     removeBtn3.setColor(255, 149, 0);
  117.     removeBtn3.setTextColor(255, 255, 255);
  118.     removeBtn3.setWidth(60);
  119.     removeBtn3.setHeight(40);
  120.    
  121.     h2.addView(removeBtn1);
  122.     h2.addView(removeBtn2);
  123.     h2.addView(removeBtn3);
  124.    
  125.     var removeButton = new Button();
  126.     removeButton.setText("移除第一个");
  127.     removeButton.setColor(255, 59, 48);
  128.     removeButton.setTextColor(255, 255, 255);
  129.     removeButton.setWidth(100);
  130.     removeButton.setHeight(40);
  131.    
  132.     removeButton.onClick(() => {
  133.         // 第二个方法:removeView移除视图
  134.         if (h2.getViewCount() > 0) {
  135.             h2.removeView(0); // 移除第一个子控件
  136.             printl("已移除第一个控件,剩余控件数: " + h2.getViewCount());
  137.         } else {
  138.             printl("没有可移除的控件");
  139.         }
  140.     });
  141.    
  142.     var removeContainer = new Horizontal();
  143.     removeContainer.setSpacing(10);
  144.     removeContainer.addView(h2);
  145.     removeContainer.addView(removeButton);
  146.    
  147.     removeViewDemo.addView(removeContainer);
  148.     demoContainer.addView(removeViewDemo);
  149.    
  150.     // 第三个方法:clearAllViews清空所有视图
  151.     var clearAllViewsDemo = new Vertical();
  152.     clearAllViewsDemo.setSpacing(5);
  153.    
  154.     var clearAllViewsLabel = new Label();
  155.     clearAllViewsLabel.setText("📌 clearAllViews清空所有视图");
  156.     clearAllViewsLabel.setFontSize(14.0);
  157.     clearAllViewsLabel.setTextColor(0, 122, 255);
  158.     clearAllViewsDemo.addView(clearAllViewsLabel);
  159.    
  160.     var h3 = new Horizontal();
  161.     h3.setSpacing(10);
  162.     h3.setBackgroundColor(240, 240, 240);
  163.    
  164.     var clearBtn1 = new Button();
  165.     clearBtn1.setText("X");
  166.     clearBtn1.setColor(0, 122, 255);
  167.     clearBtn1.setTextColor(255, 255, 255);
  168.     clearBtn1.setWidth(60);
  169.     clearBtn1.setHeight(40);
  170.    
  171.     var clearBtn2 = new Button();
  172.     clearBtn2.setText("Y");
  173.     clearBtn2.setColor(52, 199, 89);
  174.     clearBtn2.setTextColor(255, 255, 255);
  175.     clearBtn2.setWidth(60);
  176.     clearBtn2.setHeight(40);
  177.    
  178.     var clearBtn3 = new Button();
  179.     clearBtn3.setText("Z");
  180.     clearBtn3.setColor(255, 149, 0);
  181.     clearBtn3.setTextColor(255, 255, 255);
  182.     clearBtn3.setWidth(60);
  183.     clearBtn3.setHeight(40);
  184.    
  185.     h3.addView(clearBtn1);
  186.     h3.addView(clearBtn2);
  187.     h3.addView(clearBtn3);
  188.    
  189.     var clearButton = new Button();
  190.     clearButton.setText("清空所有");
  191.     clearButton.setColor(255, 59, 48);
  192.     clearButton.setTextColor(255, 255, 255);
  193.     clearButton.setWidth(100);
  194.     clearButton.setHeight(40);
  195.    
  196.     clearButton.onClick(() => {
  197.         // 第三个方法:clearAllViews清空所有视图
  198.         h3.clearAllViews(); // 清空所有控件
  199.         printl("已清空所有控件");
  200.         
  201.         // 重新添加一个提示标签
  202.         var emptyLabel = new Label();
  203.         emptyLabel.setText("已清空");
  204.         emptyLabel.setFontSize(12.0);
  205.         emptyLabel.setTextColor(100, 100, 100);
  206.         h3.addView(emptyLabel);
  207.     });
  208.    
  209.     var clearContainer = new Horizontal();
  210.     clearContainer.setSpacing(10);
  211.     clearContainer.addView(h3);
  212.     clearContainer.addView(clearButton);
  213.    
  214.     clearAllViewsDemo.addView(clearContainer);
  215.     demoContainer.addView(clearAllViewsDemo);
  216.    
  217.     // 第四个方法:getViewCount 获取视图数量
  218.     var getViewCountDemo = new Vertical();
  219.     getViewCountDemo.setSpacing(5);
  220.    
  221.     var getViewCountLabel = new Label();
  222.     getViewCountLabel.setText("📌 getViewCount 获取视图数量");
  223.     getViewCountLabel.setFontSize(14.0);
  224.     getViewCountLabel.setTextColor(0, 122, 255);
  225.     getViewCountDemo.addView(getViewCountLabel);
  226.    
  227.     var h4 = new Horizontal();
  228.     h4.setSpacing(10);
  229.     h4.setBackgroundColor(240, 240, 240);
  230.    
  231.     var countBtn1 = new Button();
  232.     countBtn1.setText("1");
  233.     countBtn1.setColor(0, 122, 255);
  234.     countBtn1.setTextColor(255, 255, 255);
  235.     countBtn1.setWidth(60);
  236.     countBtn1.setHeight(40);
  237.    
  238.     var countBtn2 = new Button();
  239.     countBtn2.setText("2");
  240.     countBtn2.setColor(52, 199, 89);
  241.     countBtn2.setTextColor(255, 255, 255);
  242.     countBtn2.setWidth(60);
  243.     countBtn2.setHeight(40);
  244.    
  245.     h4.addView(countBtn1);
  246.     h4.addView(countBtn2);
  247.    
  248.     var countButton = new Button();
  249.     countButton.setText("获取数量");
  250.     countButton.setColor(111, 66, 193);
  251.     countButton.setTextColor(255, 255, 255);
  252.     countButton.setWidth(100);
  253.     countButton.setHeight(40);
  254.    
  255.     countButton.onClick(() => {
  256.         // 第四个方法:getViewCount 获取视图数量
  257.         var count = h4.getViewCount(); // 获取子控件的数量
  258.         printl("当前控件数量: " + count);
  259.         
  260.         var resultLabel = new Label();
  261.         resultLabel.setText("控件数量: " + count);
  262.         resultLabel.setFontSize(12.0);
  263.         resultLabel.setTextColor(111, 66, 193);
  264.         getViewCountDemo.addView(resultLabel);
  265.     });
  266.    
  267.     var countContainer = new Horizontal();
  268.     countContainer.setSpacing(10);
  269.     countContainer.addView(h4);
  270.     countContainer.addView(countButton);
  271.    
  272.     getViewCountDemo.addView(countContainer);
  273.     demoContainer.addView(getViewCountDemo);
  274.    
  275.     // 第五个方法:setSpacing设置控件间距
  276.     var setSpacingDemo = new Vertical();
  277.     setSpacingDemo.setSpacing(5);
  278.    
  279.     var setSpacingLabel = new Label();
  280.     setSpacingLabel.setText("📌 setSpacing设置控件间距");
  281.     setSpacingLabel.setFontSize(14.0);
  282.     setSpacingLabel.setTextColor(0, 122, 255);
  283.     setSpacingDemo.addView(setSpacingLabel);
  284.    
  285.     var h5 = new Horizontal();
  286.     // 第五个方法:setSpacing设置控件间距
  287.     h5.setSpacing(20); // 设置控件间距为20
  288.     h5.setBackgroundColor(240, 240, 240);
  289.    
  290.     var spacingBtn1 = new Button();
  291.     spacingBtn1.setText("间距大");
  292.     spacingBtn1.setColor(0, 122, 255);
  293.     spacingBtn1.setTextColor(255, 255, 255);
  294.     spacingBtn1.setWidth(80);
  295.     spacingBtn1.setHeight(40);
  296.    
  297.     var spacingBtn2 = new Button();
  298.     spacingBtn2.setText("间距大");
  299.     spacingBtn2.setColor(52, 199, 89);
  300.     spacingBtn2.setTextColor(255, 255, 255);
  301.     spacingBtn2.setWidth(80);
  302.     spacingBtn2.setHeight(40);
  303.    
  304.     h5.addView(spacingBtn1);
  305.     h5.addView(spacingBtn2);
  306.    
  307.     setSpacingDemo.addView(h5);
  308.     demoContainer.addView(setSpacingDemo);
  309.    
  310.     // 第六个方法:setBackgroundColor设置背景颜色
  311.     var setBackgroundColorDemo = new Vertical();
  312.     setBackgroundColorDemo.setSpacing(5);
  313.    
  314.     var setBackgroundColorLabel = new Label();
  315.     setBackgroundColorLabel.setText("📌 setBackgroundColor设置背景颜色");
  316.     setBackgroundColorLabel.setFontSize(14.0);
  317.     setBackgroundColorLabel.setTextColor(0, 122, 255);
  318.     setBackgroundColorDemo.addView(setBackgroundColorLabel);
  319.    
  320.     var h6 = new Horizontal();
  321.     h6.setSpacing(10);
  322.     // 第六个方法:setBackgroundColor设置背景颜色
  323.     h6.setBackgroundColor(50, 100, 150); // 设置背景颜色为RGB(50,100,150)
  324.    
  325.     var bgBtn1 = new Button();
  326.     bgBtn1.setText("背景色1");
  327.     bgBtn1.setColor(255, 255, 255);
  328.     bgBtn1.setTextColor(0, 0, 0);
  329.     bgBtn1.setWidth(80);
  330.     bgBtn1.setHeight(40);
  331.    
  332.     var bgBtn2 = new Button();
  333.     bgBtn2.setText("背景色2");
  334.     bgBtn2.setColor(255, 255, 255);
  335.     bgBtn2.setTextColor(0, 0, 0);
  336.     bgBtn2.setWidth(80);
  337.     bgBtn2.setHeight(40);
  338.    
  339.     h6.addView(bgBtn1);
  340.     h6.addView(bgBtn2);
  341.    
  342.     setBackgroundColorDemo.addView(h6);
  343.     demoContainer.addView(setBackgroundColorDemo);
  344.    
  345.     // 第七个方法:setAlignment 设置对齐方式
  346.     var setAlignmentDemo = new Vertical();
  347.     setAlignmentDemo.setSpacing(5);
  348.    
  349.     var setAlignmentLabel = new Label();
  350.     setAlignmentLabel.setText("📌 setAlignment 设置对齐方式");
  351.     setAlignmentLabel.setFontSize(14.0);
  352.     setAlignmentLabel.setTextColor(0, 122, 255);
  353.     setAlignmentDemo.addView(setAlignmentLabel);
  354.    
  355.     // 居中对齐示例
  356.     var hCenter = new Horizontal();
  357.     hCenter.setSpacing(10);
  358.     hCenter.setBackgroundColor(240, 240, 240);
  359.     // 第七个方法:setAlignment 设置对齐方式
  360.     hCenter.setAlignment("center"); // 设置对齐方式为居中
  361.    
  362.     var centerBtn = new Button();
  363.     centerBtn.setText("居中");
  364.     centerBtn.setColor(0, 122, 255);
  365.     centerBtn.setTextColor(255, 255, 255);
  366.     centerBtn.setWidth(80);
  367.     centerBtn.setHeight(40);
  368.    
  369.     hCenter.addView(centerBtn);
  370.    
  371.     var centerLabel = new Label();
  372.     centerLabel.setText("居中对齐");
  373.     centerLabel.setFontSize(12.0);
  374.     centerLabel.setTextColor(100, 100, 100);
  375.    
  376.     setAlignmentDemo.addView(centerLabel);
  377.     setAlignmentDemo.addView(hCenter);
  378.    
  379.     // 左对齐示例
  380.     var hLeft = new Horizontal();
  381.     hLeft.setSpacing(10);
  382.     hLeft.setBackgroundColor(240, 240, 240);
  383.     hLeft.setAlignment("left"); // 设置对齐方式为左对齐
  384.    
  385.     var leftBtn = new Button();
  386.     leftBtn.setText("左对齐");
  387.     leftBtn.setColor(52, 199, 89);
  388.     leftBtn.setTextColor(255, 255, 255);
  389.     leftBtn.setWidth(80);
  390.     leftBtn.setHeight(40);
  391.    
  392.     hLeft.addView(leftBtn);
  393.    
  394.     var leftLabel = new Label();
  395.     leftLabel.setText("左对齐");
  396.     leftLabel.setFontSize(12.0);
  397.     leftLabel.setTextColor(100, 100, 100);
  398.    
  399.     setAlignmentDemo.addView(leftLabel);
  400.     setAlignmentDemo.addView(hLeft);
  401.    
  402.     // 右对齐示例
  403.     var hRight = new Horizontal();
  404.     hRight.setSpacing(10);
  405.     hRight.setBackgroundColor(240, 240, 240);
  406.     hRight.setAlignment("right"); // 设置对齐方式为右对齐
  407.    
  408.     var rightBtn = new Button();
  409.     rightBtn.setText("右对齐");
  410.     rightBtn.setColor(255, 149, 0);
  411.     rightBtn.setTextColor(255, 255, 255);
  412.     rightBtn.setWidth(80);
  413.     rightBtn.setHeight(40);
  414.    
  415.     hRight.addView(rightBtn);
  416.    
  417.     var rightLabel = new Label();
  418.     rightLabel.setText("右对齐");
  419.     rightLabel.setFontSize(12.0);
  420.     rightLabel.setTextColor(100, 100, 100);
  421.    
  422.     setAlignmentDemo.addView(rightLabel);
  423.     setAlignmentDemo.addView(hRight);
  424.    
  425.     demoContainer.addView(setAlignmentDemo);
  426.    
  427.     mainContainer.addView(demoContainer);
  428.    
  429.     // 实际应用示例
  430.     var applicationContainer = new Vertical();
  431.     applicationContainer.setBackgroundColor(255, 255, 255);
  432.     applicationContainer.setSpacing(15);
  433.    
  434.     var appTitle = new Label();
  435.     appTitle.setText("Horizontal实际应用示例");
  436.     appTitle.setFontSize(16.0);
  437.     appTitle.setTextColor(0, 0, 0);
  438.     appTitle.setTextAlignment("center");
  439.     applicationContainer.addView(appTitle);
  440.    
  441.     // 按钮组示例
  442.     var buttonGroup = new Horizontal();
  443.     buttonGroup.setSpacing(10);
  444.     buttonGroup.setAlignment("center");
  445.     buttonGroup.setBackgroundColor(240, 240, 240);
  446.    
  447.     var homeBtn = new Button();
  448.     homeBtn.setText("🏠 首页");
  449.     homeBtn.setColor(0, 122, 255);
  450.     homeBtn.setTextColor(255, 255, 255);
  451.     homeBtn.setWidth(80);
  452.     homeBtn.setHeight(40);
  453.    
  454.     var searchBtn = new Button();
  455.     searchBtn.setText("🔍 搜索");
  456.     searchBtn.setColor(52, 199, 89);
  457.     searchBtn.setTextColor(255, 255, 255);
  458.     searchBtn.setWidth(80);
  459.     searchBtn.setHeight(40);
  460.    
  461.     var profileBtn = new Button();
  462.     profileBtn.setText("👤 我的");
  463.     profileBtn.setColor(255, 149, 0);
  464.     profileBtn.setTextColor(255, 255, 255);
  465.     profileBtn.setWidth(80);
  466.     profileBtn.setHeight(40);
  467.    
  468.     buttonGroup.addView(homeBtn);
  469.     buttonGroup.addView(searchBtn);
  470.     buttonGroup.addView(profileBtn);
  471.    
  472.     applicationContainer.addView(buttonGroup);
  473.    
  474.     // 图标+文字组合示例
  475.     var iconTextGroup = new Horizontal();
  476.     iconTextGroup.setSpacing(20);
  477.     iconTextGroup.setAlignment("center");
  478.     iconTextGroup.setBackgroundColor(245, 245, 245);
  479.    
  480.     // 第一组
  481.     var group1 = new Vertical();
  482.     group1.setSpacing(5);
  483.     group1.setAlignment("center");
  484.    
  485.     var icon1 = new Label();
  486.     icon1.setText("📧");
  487.     icon1.setFontSize(24.0);
  488.     icon1.setTextAlignment("center");
  489.    
  490.     var text1 = new Label();
  491.     text1.setText("邮件");
  492.     text1.setFontSize(12.0);
  493.     text1.setTextAlignment("center");
  494.     text1.setTextColor(100, 100, 100);
  495.    
  496.     group1.addView(icon1);
  497.     group1.addView(text1);
  498.    
  499.     // 第二组
  500.     var group2 = new Vertical();
  501.     group2.setSpacing(5);
  502.     group2.setAlignment("center");
  503.    
  504.     var icon2 = new Label();
  505.     icon2.setText("📅");
  506.     icon2.setFontSize(24.0);
  507.     icon2.setTextAlignment("center");
  508.    
  509.     var text2 = new Label();
  510.     text2.setText("日历");
  511.     text2.setFontSize(12.0);
  512.     text2.setTextAlignment("center");
  513.     text2.setTextColor(100, 100, 100);
  514.    
  515.     group2.addView(icon2);
  516.     group2.addView(text2);
  517.    
  518.     // 第三组
  519.     var group3 = new Vertical();
  520.     group3.setSpacing(5);
  521.     group3.setAlignment("center");
  522.    
  523.     var icon3 = new Label();
  524.     icon3.setText("📷");
  525.     icon3.setFontSize(24.0);
  526.     icon3.setTextAlignment("center");
  527.    
  528.     var text3 = new Label();
  529.     text3.setText("相机");
  530.     text3.setFontSize(12.0);
  531.     text3.setTextAlignment("center");
  532.     text3.setTextColor(100, 100, 100);
  533.    
  534.     group3.addView(icon3);
  535.     group3.addView(text3);
  536.    
  537.     iconTextGroup.addView(group1);
  538.     iconTextGroup.addView(group2);
  539.     iconTextGroup.addView(group3);
  540.    
  541.     applicationContainer.addView(iconTextGroup);
  542.     mainContainer.addView(applicationContainer);
  543.    
  544.     // 控件信息区域
  545.     var infoContainer = new Vertical();
  546.     infoContainer.setBackgroundColor(236, 245, 255);
  547.     infoContainer.setSpacing(8);
  548.    
  549.     var infoTitle = new Label();
  550.     infoTitle.setText("ℹ️ Horizontal控件说明");
  551.     infoTitle.setFontSize(16.0);
  552.     infoTitle.setTextColor(0, 122, 255);
  553.     infoContainer.addView(infoTitle);
  554.    
  555.     var info1 = new Label();
  556.     info1.setText("• Horizontal控件用于水平排列子控件");
  557.     info1.setFontSize(12.0);
  558.     info1.setTextColor(52, 58, 64);
  559.     infoContainer.addView(info1);
  560.    
  561.     var info2 = new Label();
  562.     info2.setText("• 支持添加、移除、清空子控件");
  563.     info2.setFontSize(12.0);
  564.     info2.setTextColor(52, 58, 64);
  565.     infoContainer.addView(info2);
  566.    
  567.     var info3 = new Label();
  568.     info3.setText("• 可设置间距、背景色和对齐方式");
  569.     info3.setFontSize(12.0);
  570.     info3.setTextColor(52, 58, 64);
  571.     infoContainer.addView(info3);
  572.    
  573.     mainContainer.addView(infoContainer);
  574.    
  575.     // 底部按钮
  576.     var bottomContainer = new Horizontal();
  577.     bottomContainer.setSpacing(10);
  578.     bottomContainer.setAlignment("center");
  579.    
  580.     var exitBtn = new Button();
  581.     exitBtn.setText("退出示例");
  582.     exitBtn.setColor(255, 59, 48);
  583.     exitBtn.setTextColor(255, 255, 255);
  584.     exitBtn.setHeight(40);
  585.    
  586.     exitBtn.onClick(() => {
  587.         printl("退出按钮被点击");
  588.         vc.dismiss();
  589.     });
  590.    
  591.     bottomContainer.addView(exitBtn);
  592.     mainContainer.addView(bottomContainer);
  593.    
  594.     // 添加到主视图
  595.     view.addView(mainContainer);
  596.    
  597.     printl("Horizontal示例界面构建完成");
  598. });

  599. printl("Horizontal控件完整示例已启动");
复制代码








欢迎光临 B2B网络软件 (http://bbs.niubt.cn/) Powered by Discuz! X3.2