B2B网络软件

标题: AIWROK软件苹果IOS系统Ul-空白站位[Space]方法小结 [打印本页]

作者: YYPOST群发软件    时间: 4 小时前
标题: AIWROK软件苹果IOS系统Ul-空白站位[Space]方法小结

AIWROK软件苹果IOS系统Ul-空白站位[Space]方法小结 B2B网络软件 AIWROK软件苹果IOS系统Ul-空白站位[Space]方法小结 B2B网络软件 AIWROK软件苹果IOS系统Ul-空白站位[Space]方法小结 B2B网络软件

  1. //Ul-空白站位[Space]方法小结,交流QQ群711841924

  2. //第一个方法:📌setWidth设置宽度

  3. var space = new Space();
  4. space.setWidth(100.0f); // 设置空间宽度为100


  5. //第二个方法:📌setHeight设置高度

  6. var space = new Space();
  7. space.setHeight(50.0f); // 设置空间高度为50



  8. //第三个方法:📌setBackgroundColor 设置背景颜色

  9. var space = new Space();
  10. space.setBackgroundColor(255, 255, 255); // 设置空间背景颜色为白色
复制代码
📌setHeight设置高度
类别
详情说明
方法功能
设置空间的高度
方法签名
Void setHeight(Single height)
返回值
Void
参数
- Single height
:要设置的空间高度(Single
为单精度浮点类型 )
案例
var space = new Space();
space.setHeight(50.0f); // 设置空间高度为50
📌setWidth设置宽度
类别
详情说明
方法功能
设置空间的宽度
方法签名
Void setWidth(Single width)
返回值
Void
参数
- Single width
:要设置的空间宽度(Single
为单精度浮点类型 )
案例
var space = new Space();
space.setWidth(100.0f); // 设置空间宽度为100
📌setBackgroundColor 设置背景颜色
类别
详情说明
方法功能
设置空间的背景颜色
方法签名
Void setBackgroundColor(Single red, Single green, Single blue)
返回值
Void
参数
- Single red
:红色分量(通常取值范围 0~255
的单精度浮点数)
- Single green
:绿色分量(通常取值范围 0~255
的单精度浮点数)
- Single blue
:蓝色分量(通常取值范围 0~255
的单精度浮点数)
案例
var space = new Space();
space.setBackgroundColor(255, 255, 255); // 设置空间背景颜色为白色
完整示例:

  1. // 🔨🍎UI-空白站位[Space]方法完整示例
  2. // UI-空白站位[Space]方法小结,交流QQ群711841924

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

  4. var vc = new IOSView();
  5. vc.show(() => {
  6.     printl("Space示例界面已加载");
  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(0); // 调整间距
  20. titleContainer.setBackgroundColor(0, 122, 255);

  21. var titleLabel = new Label();
  22. titleLabel.setText("🔨 Space控件演示");
  23. titleLabel.setFontSize(20.0);
  24. titleLabel.setTextColor(255, 255, 255);
  25. titleLabel.setTextAlignment("center");

  26. var subtitleLabel = new Label();
  27. subtitleLabel.setText("空白站位控件的使用方法");
  28. subtitleLabel.setFontSize(14.0);
  29. subtitleLabel.setTextColor(255, 255, 255);
  30. subtitleLabel.setTextAlignment("center");

  31. titleContainer.addView(titleLabel);
  32. titleContainer.addView(subtitleLabel);
  33. mainContainer.addView(titleContainer);
  34.    
  35.     // Space方法演示区域
  36.     var demoContainer = new Vertical();
  37.     demoContainer.setBackgroundColor(255, 255, 255);
  38.     demoContainer.setSpacing(10);
  39.    
  40.     var demoTitle = new Label();
  41.     demoTitle.setText("Space控件功能演示");
  42.     demoTitle.setFontSize(16.0);
  43.     demoTitle.setTextColor(0, 0, 0);
  44.     demoTitle.setTextAlignment("center");
  45.     demoContainer.addView(demoTitle);
  46.    
  47.     // 第一个方法:setWidth设置宽度演示
  48.     var widthDemo = new Vertical();
  49.     widthDemo.setSpacing(5);
  50.    
  51.     var widthLabel = new Label();
  52.     widthLabel.setText("📌 setWidth设置宽度");
  53.     widthLabel.setFontSize(14.0);
  54.     widthLabel.setTextColor(0, 122, 255);
  55.     widthDemo.addView(widthLabel);
  56.    
  57.     var widthDesc = new Label();
  58.     widthDesc.setText("创建不同宽度的空白占位:");
  59.     widthDesc.setFontSize(12.0);
  60.     widthDesc.setTextColor(100, 100, 100);
  61.     widthDemo.addView(widthDesc);
  62.    
  63.     // 水平容器展示不同宽度的Space
  64.     var widthContainer = new Horizontal();
  65.     widthContainer.setSpacing(5);
  66.     widthContainer.setBackgroundColor(240, 240, 240);
  67.    
  68.     var label1 = new Label();
  69.     label1.setText("W20");
  70.     label1.setFontSize(10.0);
  71.     label1.setBackgroundColor(0, 122, 255);
  72.     label1.setTextColor(255, 255, 255);
  73.    
  74.     // 第一个方法:setWidth设置宽度
  75.     var space1 = new Space();
  76.     space1.setWidth(20.0); // 设置空间宽度为20
  77.     space1.setBackgroundColor(200, 200, 200); // 设置背景色以便观察
  78.    
  79.     var label2 = new Label();
  80.     label2.setText("W50");
  81.     label2.setFontSize(10.0);
  82.     label2.setBackgroundColor(52, 199, 89);
  83.     label2.setTextColor(255, 255, 255);
  84.    
  85.     // 第一个方法:setWidth设置宽度
  86.     var space2 = new Space();
  87.     space2.setWidth(50.0); // 设置空间宽度为50
  88.     space2.setBackgroundColor(200, 200, 200); // 设置背景色以便观察
  89.    
  90.     var label3 = new Label();
  91.     label3.setText("W30");
  92.     label3.setFontSize(10.0);
  93.     label3.setBackgroundColor(255, 149, 0);
  94.     label3.setTextColor(255, 255, 255);
  95.    
  96.     widthContainer.addView(label1);
  97.     widthContainer.addView(space1);
  98.     widthContainer.addView(label2);
  99.     widthContainer.addView(space2);
  100.     widthContainer.addView(label3);
  101.     widthDemo.addView(widthContainer);
  102.     demoContainer.addView(widthDemo);
  103.    
  104.     // 添加分割空间
  105.     var separator1 = new Space();
  106.     separator1.setHeight(10.0);
  107.     demoContainer.addView(separator1);
  108.    
  109.     // 第二个方法:setHeight设置高度演示
  110.     var heightDemo = new Vertical();
  111.     heightDemo.setSpacing(5);
  112.    
  113.     var heightLabel = new Label();
  114.     heightLabel.setText("📌 setHeight设置高度");
  115.     heightLabel.setFontSize(14.0);
  116.     heightLabel.setTextColor(0, 122, 255);
  117.     heightDemo.addView(heightLabel);
  118.    
  119.     var heightDesc = new Label();
  120.     heightDesc.setText("创建不同高度的空白占位:");
  121.     heightDesc.setFontSize(12.0);
  122.     heightDesc.setTextColor(100, 100, 100);
  123.     heightDemo.addView(heightDesc);
  124.    
  125.     // 垂直容器展示不同高度的Space
  126.     var heightContainer = new Vertical();
  127.     heightContainer.setBackgroundColor(240, 240, 240);
  128.    
  129.     var hLabel1 = new Label();
  130.     hLabel1.setText("H10");
  131.     hLabel1.setFontSize(10.0);
  132.     hLabel1.setBackgroundColor(0, 122, 255);
  133.     hLabel1.setTextColor(255, 255, 255);
  134.     hLabel1.setTextAlignment("center");
  135.    
  136.     // 第二个方法:setHeight设置高度
  137.     var space3 = new Space();
  138.     space3.setHeight(10.0); // 设置空间高度为10
  139.     space3.setBackgroundColor(200, 200, 200); // 设置背景色以便观察
  140.    
  141.     var hLabel2 = new Label();
  142.     hLabel2.setText("H25");
  143.     hLabel2.setFontSize(10.0);
  144.     hLabel2.setBackgroundColor(52, 199, 89);
  145.     hLabel2.setTextColor(255, 255, 255);
  146.     hLabel2.setTextAlignment("center");
  147.    
  148.     // 第二个方法:setHeight设置高度
  149.     var space4 = new Space();
  150.     space4.setHeight(25.0); // 设置空间高度为25
  151.     space4.setBackgroundColor(200, 200, 200); // 设置背景色以便观察
  152.    
  153.     var hLabel3 = new Label();
  154.     hLabel3.setText("H15");
  155.     hLabel3.setFontSize(10.0);
  156.     hLabel3.setBackgroundColor(255, 149, 0);
  157.     hLabel3.setTextColor(255, 255, 255);
  158.     hLabel3.setTextAlignment("center");
  159.    
  160.     heightContainer.addView(hLabel1);
  161.     heightContainer.addView(space3);
  162.     heightContainer.addView(hLabel2);
  163.     heightContainer.addView(space4);
  164.     heightContainer.addView(hLabel3);
  165.     heightDemo.addView(heightContainer);
  166.     demoContainer.addView(heightDemo);
  167.    
  168.     // 添加分割空间
  169.     var separator2 = new Space();
  170.     separator2.setHeight(10.0);
  171.     demoContainer.addView(separator2);
  172.    
  173.     // 第三个方法:setBackgroundColor 设置背景颜色演示
  174.     var colorDemo = new Vertical();
  175.     colorDemo.setSpacing(5);
  176.    
  177.     var colorLabel = new Label();
  178.     colorLabel.setText("📌 setBackgroundColor设置背景颜色");
  179.     colorLabel.setFontSize(14.0);
  180.     colorLabel.setTextColor(0, 122, 255);
  181.     colorDemo.addView(colorLabel);
  182.    
  183.     var colorDesc = new Label();
  184.     colorDesc.setText("创建不同背景颜色的空白占位:");
  185.     colorDesc.setFontSize(12.0);
  186.     colorDesc.setTextColor(100, 100, 100);
  187.     colorDemo.addView(colorDesc);
  188.    
  189.     // 水平容器展示不同背景色的Space
  190.     var colorContainer = new Horizontal();
  191.     colorContainer.setSpacing(5);
  192.    
  193.     // 第三个方法:setBackgroundColor 设置背景颜色
  194.     var space5 = new Space();
  195.     space5.setWidth(40.0);
  196.     space5.setHeight(40.0);
  197.     space5.setBackgroundColor(255, 0, 0); // 红色
  198.    
  199.     // 第三个方法:setBackgroundColor 设置背景颜色
  200.     var space6 = new Space();
  201.     space6.setWidth(40.0);
  202.     space6.setHeight(40.0);
  203.     space6.setBackgroundColor(0, 255, 0); // 绿色
  204.    
  205.     // 第三个方法:setBackgroundColor 设置背景颜色
  206.     var space7 = new Space();
  207.     space7.setWidth(40.0);
  208.     space7.setHeight(40.0);
  209.     space7.setBackgroundColor(0, 0, 255); // 蓝色
  210.    
  211.     // 第三个方法:setBackgroundColor 设置背景颜色
  212.     var space8 = new Space();
  213.     space8.setWidth(40.0);
  214.     space8.setHeight(40.0);
  215.     space8.setBackgroundColor(255, 255, 0); // 黄色
  216.    
  217.     colorContainer.addView(space5);
  218.     colorContainer.addView(space6);
  219.     colorContainer.addView(space7);
  220.     colorContainer.addView(space8);
  221.     colorDemo.addView(colorContainer);
  222.     demoContainer.addView(colorDemo);
  223.    
  224.     mainContainer.addView(demoContainer);
  225.    
  226.     // Space实际应用示例
  227.     var applicationContainer = new Vertical();
  228.     applicationContainer.setBackgroundColor(255, 255, 255);
  229.     applicationContainer.setSpacing(10);
  230.    
  231.     var appTitle = new Label();
  232.     appTitle.setText("Space实际应用示例");
  233.     appTitle.setFontSize(16.0);
  234.     appTitle.setTextColor(0, 0, 0);
  235.     appTitle.setTextAlignment("center");
  236.     applicationContainer.addView(appTitle);
  237.    
  238.     var appDesc = new Label();
  239.     appDesc.setText("使用Space控件优化界面布局:");
  240.     appDesc.setFontSize(12.0);
  241.     appDesc.setTextColor(100, 100, 100);
  242.     applicationContainer.addView(appDesc);
  243.    
  244.     // 表单布局示例
  245.     var formContainer = new Vertical();
  246.     formContainer.setSpacing(10);
  247.    
  248.     // 用户名行
  249.     var usernameRow = new Horizontal();
  250.     usernameRow.setSpacing(10);
  251.    
  252.     var usernameLabel = new Label();
  253.     usernameLabel.setText("用户名:");
  254.     usernameLabel.setWidth(60);
  255.     usernameLabel.setTextColor(0, 0, 0);
  256.    
  257.     var usernameInput = new Label();
  258.     usernameInput.setText("ZhangSan");
  259.     usernameInput.setBackgroundColor(240, 240, 240);
  260.    
  261.     usernameRow.addView(usernameLabel);
  262.     usernameRow.addView(usernameInput);
  263.     formContainer.addView(usernameRow);
  264.    
  265.     // 添加垂直间距
  266.     var formSpace = new Space();
  267.     formSpace.setHeight(15.0);
  268.     formContainer.addView(formSpace);
  269.    
  270.     // 密码行
  271.     var passwordRow = new Horizontal();
  272.     passwordRow.setSpacing(10);
  273.    
  274.     var passwordLabel = new Label();
  275.     passwordLabel.setText("密码:");
  276.     passwordLabel.setWidth(60);
  277.     passwordLabel.setTextColor(0, 0, 0);
  278.    
  279.     var passwordInput = new Label();
  280.     passwordInput.setText("********");
  281.     passwordInput.setBackgroundColor(240, 240, 240);
  282.    
  283.     passwordRow.addView(passwordLabel);
  284.     passwordRow.addView(passwordInput);
  285.     formContainer.addView(passwordRow);
  286.    
  287.     applicationContainer.addView(formContainer);
  288.    
  289.     // 按钮区域
  290.     var buttonContainer = new Horizontal();
  291.     buttonContainer.setSpacing(10);
  292.     buttonContainer.setAlignment("center");
  293.    
  294.     // 使用Space创建左右间距
  295.     var leftSpace = new Space();
  296.     leftSpace.setWidth(20.0);
  297.    
  298.     var loginBtn = new Button();
  299.     loginBtn.setText("登录");
  300.     loginBtn.setColor(0, 122, 255);
  301.     loginBtn.setTextColor(255, 255, 255);
  302.     loginBtn.setWidth(100);
  303.     loginBtn.setHeight(40);
  304.    
  305.     var registerBtn = new Button();
  306.     registerBtn.setText("注册");
  307.     registerBtn.setColor(52, 199, 89);
  308.     registerBtn.setTextColor(255, 255, 255);
  309.     registerBtn.setWidth(100);
  310.     registerBtn.setHeight(40);
  311.    
  312.     var rightSpace = new Space();
  313.     rightSpace.setWidth(20.0);
  314.    
  315.     buttonContainer.addView(leftSpace);
  316.     buttonContainer.addView(loginBtn);
  317.     buttonContainer.addView(registerBtn);
  318.     buttonContainer.addView(rightSpace);
  319.    
  320.     applicationContainer.addView(buttonContainer);
  321.     mainContainer.addView(applicationContainer);
  322.    
  323.     // 控件信息区域
  324.     var infoContainer = new Vertical();
  325.     infoContainer.setBackgroundColor(236, 245, 255);
  326.     infoContainer.setSpacing(8);
  327.    
  328.     var infoTitle = new Label();
  329.     infoTitle.setText("ℹ️ Space控件说明");
  330.     infoTitle.setFontSize(16.0);
  331.     infoTitle.setTextColor(0, 122, 255);
  332.     infoContainer.addView(infoTitle);
  333.    
  334.     var info1 = new Label();
  335.     info1.setText("• Space控件用于创建空白占位区域");
  336.     info1.setFontSize(12.0);
  337.     info1.setTextColor(52, 58, 64);
  338.     infoContainer.addView(info1);
  339.    
  340.     var info2 = new Label();
  341.     info2.setText("• 可通过setWidth/setHeight设置尺寸");
  342.     info2.setFontSize(12.0);
  343.     info2.setTextColor(52, 58, 64);
  344.     infoContainer.addView(info2);
  345.    
  346.     var info3 = new Label();
  347.     info3.setText("• 可通过setBackgroundColor设置背景色");
  348.     info3.setFontSize(12.0);
  349.     info3.setTextColor(52, 58, 64);
  350.     infoContainer.addView(info3);
  351.    
  352.     var info4 = new Label();
  353.     info4.setText("• 常用于界面布局优化和元素间距控制");
  354.     info4.setFontSize(12.0);
  355.     info4.setTextColor(52, 58, 64);
  356.     infoContainer.addView(info4);
  357.    
  358.     mainContainer.addView(infoContainer);
  359.    
  360.     // 底部按钮
  361.     var bottomContainer = new Horizontal();
  362.     bottomContainer.setSpacing(10);
  363.     bottomContainer.setAlignment("center");
  364.    
  365.     var exitBtn = new Button();
  366.     exitBtn.setText("退出示例");
  367.     exitBtn.setColor(255, 59, 48);
  368.     exitBtn.setTextColor(255, 255, 255);
  369.     exitBtn.setHeight(40);
  370.    
  371.     exitBtn.onClick(() => {
  372.         printl("退出按钮被点击");
  373.         vc.dismiss();
  374.     });
  375.    
  376.     bottomContainer.addView(exitBtn);
  377.     mainContainer.addView(bottomContainer);
  378.    
  379.     // 添加到主视图
  380.     view.addView(mainContainer);
  381.    
  382.     printl("Space示例界面构建完成");
  383. });

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






AIWROK软件苹果IOS系统Ul-空白站位[Space]方法小结






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