B2B网络软件

 找回密码
 立即注册 审核网站号:QQ:896757558
搜索
查看: 430|回复: 0
打印 上一主题 下一主题

AIWROK软件苹果UI按钮Button方法示例

[复制链接]

1186

主题

1191

帖子

8021

积分

abc

Rank: 9Rank: 9Rank: 9

积分
8021
跳转到指定楼层
楼主
发表于 2026-2-13 08:58:50 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

AIWROK软件苹果UI按钮Button方法示例
AIWROK软件苹果UI按钮Button方法示例 B2B网络软件

AIWROK软件苹果UI按钮Button方法示例 B2B网络软件

AIWROK软件苹果UI按钮Button方法示例 B2B网络软件



  1. // Button综合示例 - 全面展示Button的各种用法和样式
  2. // // 🍎交流QQ群711841924群一,苹果内测群:528816639

  3. // 创建TabView
  4. var tab = new TabView();

  5. // 设置Tab标题
  6. var titles = ["Button示例"];
  7. tab.setTitles(titles);

  8. // 创建主界面
  9. var mainView = new Vertical();
  10. mainView.setBackgroundColor(245, 245, 245);
  11. mainView.setSpacing(20);

  12. // 添加标题
  13. var titleLabel = new Label();
  14. titleLabel.setText("Button综合示例");
  15. titleLabel.setTextColor(50, 100, 150);
  16. titleLabel.setFontSize(24);
  17. mainView.addView(titleLabel);

  18. // 添加基本按钮示例
  19. addSection(mainView, "基本按钮示例");
  20. addBasicButtonExample(mainView);

  21. // 添加彩色按钮示例
  22. addSection(mainView, "彩色按钮示例");
  23. addColorButtonExample(mainView);

  24. // 添加交互按钮示例
  25. addSection(mainView, "交互按钮示例");
  26. addInteractiveButtonExample(mainView);

  27. // 添加状态按钮示例
  28. addSection(mainView, "状态按钮示例");
  29. addStateButtonExample(mainView);

  30. // 添加布局按钮示例
  31. addSection(mainView, "布局按钮示例");
  32. addLayoutButtonExample(mainView);

  33. // 添加高级按钮示例
  34. addSection(mainView, "高级按钮示例");
  35. addAdvancedButtonExample(mainView);

  36. // 显示主界面
  37. tab.show(() => {
  38.     printl("Button示例界面已加载完成");
  39.     tab.addView(0, mainView);
  40. });

  41. // 添加 section 标题
  42. function addSection(container, title) {
  43.     var sectionLabel = new Label();
  44.     sectionLabel.setText(title);
  45.     sectionLabel.setTextColor(80, 80, 80);
  46.     sectionLabel.setFontSize(18);
  47.     // 添加间距标签作为替代
  48.     var spacing = new Label();
  49.     spacing.setHeight(20);
  50.     container.addView(spacing);
  51.     container.addView(sectionLabel);
  52.     var bottomSpacing = new Label();
  53.     bottomSpacing.setHeight(10);
  54.     container.addView(bottomSpacing);
  55. }

  56. // 基本按钮示例
  57. function addBasicButtonExample(container) {
  58.     var buttonContainer = new Horizontal();
  59.     buttonContainer.setSpacing(20);
  60.    
  61.     // 基本按钮
  62.     var basicBtn = new Button();
  63.     basicBtn.setText("基本按钮");
  64.     basicBtn.setWidth(120);
  65.     basicBtn.setHeight(40);
  66.     basicBtn.onClick(() => {
  67.         printl("基本按钮被点击");
  68.         showToast("基本按钮被点击");
  69.     });
  70.     buttonContainer.addView(basicBtn);
  71.    
  72.     // 获取按钮文本
  73.     var getTextBtn = new Button();
  74.     getTextBtn.setText("获取文本");
  75.     getTextBtn.setWidth(120);
  76.     getTextBtn.setHeight(40);
  77.     getTextBtn.onClick(() => {
  78.         var text = getTextBtn.getText();
  79.         printl("按钮文本: " + text);
  80.         showToast("按钮文本: " + text);
  81.     });
  82.     buttonContainer.addView(getTextBtn);
  83.    
  84.     container.addView(buttonContainer);
  85. }

  86. // 彩色按钮示例
  87. function addColorButtonExample(container) {
  88.     var buttonContainer = new Horizontal();
  89.     buttonContainer.setSpacing(15);
  90.    
  91.     // 蓝色按钮
  92.     var blueBtn = new Button();
  93.     blueBtn.setText("蓝色按钮");
  94.     blueBtn.setColor(50, 100, 150);
  95.     blueBtn.setTextColor(255, 255, 255);
  96.     blueBtn.setWidth(100);
  97.     blueBtn.setHeight(40);
  98.     blueBtn.onClick(() => {
  99.         showToast("蓝色按钮被点击");
  100.     });
  101.     buttonContainer.addView(blueBtn);
  102.    
  103.     // 红色按钮
  104.     var redBtn = new Button();
  105.     redBtn.setText("红色按钮");
  106.     redBtn.setColor(200, 50, 50);
  107.     redBtn.setTextColor(255, 255, 255);
  108.     redBtn.setWidth(100);
  109.     redBtn.setHeight(40);
  110.     redBtn.onClick(() => {
  111.         showToast("红色按钮被点击");
  112.     });
  113.     buttonContainer.addView(redBtn);
  114.    
  115.     // 绿色按钮
  116.     var greenBtn = new Button();
  117.     greenBtn.setText("绿色按钮");
  118.     greenBtn.setColor(50, 150, 50);
  119.     greenBtn.setTextColor(255, 255, 255);
  120.     greenBtn.setWidth(100);
  121.     greenBtn.setHeight(40);
  122.     greenBtn.onClick(() => {
  123.         showToast("绿色按钮被点击");
  124.     });
  125.     buttonContainer.addView(greenBtn);
  126.    
  127.     container.addView(buttonContainer);
  128. }

  129. // 交互按钮示例
  130. function addInteractiveButtonExample(container) {
  131.     var buttonContainer = new Vertical();
  132.     buttonContainer.setSpacing(15);
  133.    
  134.     // 计数器按钮
  135.     var count = 0;
  136.     var countBtn = new Button();
  137.     countBtn.setText("点击次数: " + count);
  138.     countBtn.setWidth(200);
  139.     countBtn.setHeight(45);
  140.     countBtn.setColor(70, 130, 180);
  141.     countBtn.setTextColor(255, 255, 255);
  142.     countBtn.onClick(() => {
  143.         count++;
  144.         countBtn.setText("点击次数: " + count);
  145.         showToast("点击次数: " + count);
  146.     });
  147.     buttonContainer.addView(countBtn);
  148.    
  149.     // 切换文本按钮
  150.     var toggleBtn = new Button();
  151.     toggleBtn.setText("显示更多");
  152.     toggleBtn.setWidth(150);
  153.     toggleBtn.setHeight(40);
  154.     toggleBtn.onClick(() => {
  155.         var currentText = toggleBtn.getText();
  156.         if (currentText === "显示更多") {
  157.             toggleBtn.setText("显示更少");
  158.         } else {
  159.             toggleBtn.setText("显示更多");
  160.         }
  161.         showToast("按钮文本已切换");
  162.     });
  163.     buttonContainer.addView(toggleBtn);
  164.    
  165.     container.addView(buttonContainer);
  166. }

  167. // 状态按钮示例
  168. function addStateButtonExample(container) {
  169.     var buttonContainer = new Horizontal();
  170.     buttonContainer.setSpacing(20);
  171.    
  172.     // 启用/禁用按钮
  173.     var enableBtn = new Button();
  174.     enableBtn.setText("禁用按钮");
  175.     enableBtn.setWidth(120);
  176.     enableBtn.setHeight(40);
  177.     enableBtn.setColor(150, 150, 150);
  178.     enableBtn.setTextColor(255, 255, 255);
  179.    
  180.     var targetBtn = new Button();
  181.     targetBtn.setText("目标按钮");
  182.     targetBtn.setWidth(120);
  183.     targetBtn.setHeight(40);
  184.     targetBtn.onClick(() => {
  185.         showToast("目标按钮被点击");
  186.     });
  187.    
  188.     enableBtn.onClick(() => {
  189.         var currentText = enableBtn.getText();
  190.         if (currentText === "禁用按钮") {
  191.             enableBtn.setText("启用按钮");
  192.             targetBtn.setColor(150, 150, 150);
  193.             targetBtn.setTextColor(200, 200, 200);
  194.             // 实际应用中可能需要设置一个标志来禁用点击
  195.             showToast("按钮已禁用");
  196.         } else {
  197.             enableBtn.setText("禁用按钮");
  198.             targetBtn.setColor(50, 100, 150);
  199.             targetBtn.setTextColor(255, 255, 255);
  200.             showToast("按钮已启用");
  201.         }
  202.     });
  203.    
  204.     buttonContainer.addView(enableBtn);
  205.     buttonContainer.addView(targetBtn);
  206.    
  207.     container.addView(buttonContainer);
  208. }

  209. // 布局按钮示例
  210. function addLayoutButtonExample(container) {
  211.     var buttonContainer = new Vertical();
  212.     buttonContainer.setSpacing(15);
  213.    
  214.     // 水平布局按钮组
  215.     var horizontalGroup = new Horizontal();
  216.     horizontalGroup.setSpacing(10);
  217.    
  218.     var hBtn1 = new Button();
  219.     hBtn1.setText("按钮1");
  220.     hBtn1.setWidth(80);
  221.     hBtn1.setHeight(40);
  222.     hBtn1.onClick(() => showToast("按钮1被点击"));
  223.    
  224.     var hBtn2 = new Button();
  225.     hBtn2.setText("按钮2");
  226.     hBtn2.setWidth(80);
  227.     hBtn2.setHeight(40);
  228.     hBtn2.onClick(() => showToast("按钮2被点击"));
  229.    
  230.     var hBtn3 = new Button();
  231.     hBtn3.setText("按钮3");
  232.     hBtn3.setWidth(80);
  233.     hBtn3.setHeight(40);
  234.     hBtn3.onClick(() => showToast("按钮3被点击"));
  235.    
  236.     horizontalGroup.addView(hBtn1);
  237.     horizontalGroup.addView(hBtn2);
  238.     horizontalGroup.addView(hBtn3);
  239.    
  240.     buttonContainer.addView(horizontalGroup);
  241.    
  242.     // 垂直布局按钮组
  243.     var verticalGroup = new Vertical();
  244.     verticalGroup.setSpacing(10);
  245.    
  246.     var vBtn1 = new Button();
  247.     vBtn1.setText("垂直按钮1");
  248.     vBtn1.setWidth(150);
  249.     vBtn1.setHeight(40);
  250.     vBtn1.onClick(() => showToast("垂直按钮1被点击"));
  251.    
  252.     var vBtn2 = new Button();
  253.     vBtn2.setText("垂直按钮2");
  254.     vBtn2.setWidth(150);
  255.     vBtn2.setHeight(40);
  256.     vBtn2.onClick(() => showToast("垂直按钮2被点击"));
  257.    
  258.     verticalGroup.addView(vBtn1);
  259.     verticalGroup.addView(vBtn2);
  260.    
  261.     buttonContainer.addView(verticalGroup);
  262.    
  263.     container.addView(buttonContainer);
  264. }

  265. // 高级按钮示例
  266. function addAdvancedButtonExample(container) {
  267.     var buttonContainer = new Vertical();
  268.     buttonContainer.setSpacing(15);
  269.    
  270.     // 带图标效果的按钮(模拟)
  271.     var iconBtn = new Button();
  272.     iconBtn.setText("🔍 搜索");
  273.     iconBtn.setWidth(120);
  274.     iconBtn.setHeight(40);
  275.     iconBtn.setColor(70, 130, 180);
  276.     iconBtn.setTextColor(255, 255, 255);
  277.     iconBtn.onClick(() => {
  278.         showToast("搜索按钮被点击");
  279.     });
  280.     buttonContainer.addView(iconBtn);
  281.    
  282.     // 长文本按钮
  283.     var longTextBtn = new Button();
  284.     longTextBtn.setText("这是一个很长很长的按钮文本示例");
  285.     longTextBtn.setWidth(200);
  286.     longTextBtn.setHeight(40);
  287.     longTextBtn.onClick(() => {
  288.         showToast("长文本按钮被点击");
  289.     });
  290.     buttonContainer.addView(longTextBtn);
  291.    
  292.     // 确认/取消按钮组
  293.     var confirmGroup = new Horizontal();
  294.     confirmGroup.setSpacing(20);
  295.    
  296.     var confirmBtn = new Button();
  297.     confirmBtn.setText("确认");
  298.     confirmBtn.setWidth(100);
  299.     confirmBtn.setHeight(40);
  300.     confirmBtn.setColor(50, 150, 50);
  301.     confirmBtn.setTextColor(255, 255, 255);
  302.     confirmBtn.onClick(() => {
  303.         showToast("确认操作");
  304.     });
  305.    
  306.     var cancelBtn = new Button();
  307.     cancelBtn.setText("取消");
  308.     cancelBtn.setWidth(100);
  309.     cancelBtn.setHeight(40);
  310.     cancelBtn.setColor(150, 150, 150);
  311.     cancelBtn.setTextColor(255, 255, 255);
  312.     cancelBtn.onClick(() => {
  313.         showToast("取消操作");
  314.     });
  315.    
  316.     confirmGroup.addView(confirmBtn);
  317.     confirmGroup.addView(cancelBtn);
  318.    
  319.     buttonContainer.addView(confirmGroup);
  320.    
  321.     container.addView(buttonContainer);
  322. }

  323. // 显示提示信息
  324. function showToast(message) {
  325.     printl("提示: " + message);
  326.     // 实际应用中可以调用原生的toast功能
  327. }

  328. // 日志输出函数
  329. function printl(message) {
  330.     console.log("[Button Example] " + message);
  331. }

  332. // 代码说明:
  333. // 1. 本示例展示了Button的各种用法和样式
  334. // 2. 包括基本按钮、彩色按钮、交互按钮、状态按钮、布局按钮和高级按钮
  335. // 3. 实现了按钮点击事件、文本修改、颜色变化等交互功能
  336. // 4. 代码遵循AIWROK平台的方法规范
  337. // 5. 可以根据实际需求修改和扩展功能
复制代码


回复

使用道具 举报

本版积分规则

关闭

QQ|»营销软件综合讨论|»营销软件有问必答|»营销软件教程专区|»营销软件POST脚本分享|»营销软件普通脚本分享|»营销软件软件资讯|»营销软件精品软件|»营销软件更新公告|营销软件|B2B软件|B2B网络软件 ( 京ICP备09078825号 )本网站开发的营销软件是一款新的网络营销软件,这款营销可以去网站软件,博客软件,B2B软件,分类信息网发贴,可以抢沙发,可以到百度文库上传WORD文档,可以到一些是相册网站自动上传图片,这个自动发帖软件自带云蜘蛛,加快收录,有6种对接打码接口,方便,效率高,速度快,而且对拖动的验证码全网第一家独家支持,全部原创技术,独家研发,正版原创带版权软件。选择万能营销软件,就选择了一种赚钱的效率,从没有被超越过,一直在努力研发新技术。放飞梦想,解放双手,来点创意,成就你的梦想,就在万能营销软件开始

map2

GMT+8, 2026-10-3 13:09 , Processed in 0.403639 second(s), 36 queries .

快速回复 返回顶部 返回列表