YYPOST群发软件 发表于 6 天前

AIWROK苹果脚本实例1界面UI输入框类[Input]


AIWROK苹果脚本实例1界面UI输入框类







// =============================================================================
// 🎨 UI-输入框类全新系统化示例
// 📱 适用于苹果iOS系统 - AIWROK IDE
//🍎交流QQ群711841924群一,苹果内测群,528816639
// =============================================================================
//
// 本示例全面展示Input控件的所有功能,采用TabView多页面架构,
// 系统化地演示每个方法的使用场景和最佳实践。
//
// Input控件方法清单:
// 1. setText(text) - 设置输入框文本内容
// 2. getText() - 获取输入框文本内容
// 3. setID(id) - 设置控件唯一标识符
// 4. setDefultText(text) - 设置默认文本(配合config使用)
// 5. setTextColor(r, g, b) - 设置文本颜色
// 6. setFontSize(size) - 设置字体大小
// 7. setBackgroundColor(r, g, b) - 设置背景颜色
// 8. setWidth(width) - 设置控件宽度
// 9. setHeight(height) - 设置控件高度
// 10. setPlaceholder(text) - 设置占位提示文本
// 11. setTextAlignment(align) - 设置文本对齐方式
// 12. setInputStyle(isLineStyle) - 设置输入框样式
// =============================================================================

printl("=== Input输入框控件全新系统化示例启动 ===");

// 创建TabView主容器
var tab = new TabView();

// 设置Tab页面标题
var tabTitles = [
    "基础",
    "样式",
    "高级",
    "综合",
    "关于"
];
tab.setTitles(tabTitles);

// 显示TabView并初始化所有页面
tab.show(function() {
    // 构建各个页面
    buildBasicPage();
    buildStylePage();
    buildAdvancedPage();
    buildApplicationPage();
    buildAboutPage();
});

// =============================================================================
// 第一页:基础方法演示
// =============================================================================
function buildBasicPage() {
    var page = new Vertical();
    page.setSpacing(0);
    page.setBackgroundColor(245, 245, 250);

    // 方法1:setText - 设置文本
    var section1 = createMethodSection(
      "方法1:setText",
      "设置输入框的文本内容",
      "input.setText(\"Hello World\");"
    );
   
    var input1 = new Input();
    input1.setText("预设的文本内容");
    input1.setWidth(280);
    input1.setHeight(42);
    input1.setBackgroundColor(255, 255, 255);
    section1.addView(input1);
   
    var btn1 = createActionButton("修改文本", function() {
      input1.setText("文本已被修改!");
      printl("setText方法演示:文本已修改");
    });
    section1.addView(btn1);
    page.addView(section1);
   
    // 方法2:getText - 获取文本
    var section2 = createMethodSection(
      "方法2:getText",
      "获取输入框当前文本内容",
      "var text = input.getText();"
    );
   
    var input2 = new Input();
    input2.setPlaceholder("在此输入内容后点击获取");
    input2.setWidth(280);
    input2.setHeight(42);
    input2.setBackgroundColor(255, 255, 255);
    section2.addView(input2);
   
    var resultLabel2 = createResultLabel("等待获取...");
   
    var btn2 = createActionButton("获取文本", function() {
      var text = input2.getText();
      resultLabel2.setText("获取结果: \"" + text + "\"");
      printl("getText方法演示:获取到文本 \"" + text + "\"");
    });
    section2.addView(btn2);
    section2.addView(resultLabel2);
    page.addView(section2);
   
    // 方法3:setID - 设置控件ID
    var section3 = createMethodSection(
      "方法3:setID",
      "设置控件唯一标识符,用于配置存储",
      "input.setID(\"username\");"
    );
   
    var input3 = new Input();
    input3.setID("demo_input_id");
    input3.setPlaceholder("已设置ID: demo_input_id");
    input3.setWidth(280);
    input3.setHeight(42);
    input3.setBackgroundColor(255, 255, 255);
    section3.addView(input3);
   
    var btn3 = createActionButton("读取配置", function() {
      var configValue = config.getConfig("demo_input_id");
      printl("setID方法演示:从config读取到值 \"" + configValue + "\"");
    });
    section3.addView(btn3);
    page.addView(section3);
   
    // 方法4:setDefultText - 设置默认文本
    var section4 = createMethodSection(
      "方法4:setDefultText",
      "设置输入框的默认文本值",
      "input.setDefultText(\"默认值\");"
    );
   
    var input4 = new Input();
    input4.setID("default_text_demo");
    input4.setDefultText("这是默认文本");
    input4.setWidth(280);
    input4.setHeight(42);
    input4.setBackgroundColor(255, 255, 255);
    section4.addView(input4);
   
    var infoLabel4 = createInfoLabel("配合setID使用,可通过config保存/读取默认值");
    section4.addView(infoLabel4);
    page.addView(section4);
   
    // 添加到TabView
    tab.addView(0, page);
    printl("基础方法页面构建完成");
}

// =============================================================================
// 第二页:样式设置演示
// =============================================================================
function buildStylePage() {
    var page = new Vertical();
    page.setSpacing(0);
    page.setBackgroundColor(250, 245, 245);

    // 方法5:setTextColor - 文本颜色
    var section5 = createMethodSection(
      "方法5:setTextColor",
      "设置输入框文本颜色 (R, G, B)",
      "input.setTextColor(255, 0, 0); // 红色"
    );
   
    var colorContainer = new Horizontal();
    colorContainer.setSpacing(10);
   
    var redInput = new Input();
    redInput.setText("红色文本");
    redInput.setTextColor(255, 0, 0);
    redInput.setWidth(85);
    redInput.setHeight(40);
    redInput.setBackgroundColor(255, 235, 235);
    colorContainer.addView(redInput);
   
    var greenInput = new Input();
    greenInput.setText("绿色文本");
    greenInput.setTextColor(0, 150, 0);
    greenInput.setWidth(85);
    greenInput.setHeight(40);
    greenInput.setBackgroundColor(235, 255, 235);
    colorContainer.addView(greenInput);
   
    var blueInput = new Input();
    blueInput.setText("蓝色文本");
    blueInput.setTextColor(0, 100, 255);
    blueInput.setWidth(85);
    blueInput.setHeight(40);
    blueInput.setBackgroundColor(235, 235, 255);
    colorContainer.addView(blueInput);
   
    section5.addView(colorContainer);
    page.addView(section5);
   
    // 方法6:setFontSize - 字体大小
    var section6 = createMethodSection(
      "方法6:setFontSize",
      "设置输入框字体大小",
      "input.setFontSize(18);"
    );
   
    var fontContainer = new Vertical();
    fontContainer.setSpacing(8);
   
    var smallInput = new Input();
    smallInput.setText("小字体 (12px)");
    smallInput.setFontSize(12);
    smallInput.setWidth(280);
    smallInput.setHeight(35);
    smallInput.setBackgroundColor(255, 255, 255);
    fontContainer.addView(smallInput);
   
    var mediumInput = new Input();
    mediumInput.setText("中字体 (16px)");
    mediumInput.setFontSize(16);
    mediumInput.setWidth(280);
    mediumInput.setHeight(40);
    mediumInput.setBackgroundColor(255, 255, 255);
    fontContainer.addView(mediumInput);
   
    var largeInput = new Input();
    largeInput.setText("大字体 (20px)");
    largeInput.setFontSize(20);
    largeInput.setWidth(280);
    largeInput.setHeight(45);
    largeInput.setBackgroundColor(255, 255, 255);
    fontContainer.addView(largeInput);
   
    section6.addView(fontContainer);
    page.addView(section6);
   
    // 方法7:setBackgroundColor - 背景颜色
    var section7 = createMethodSection(
      "方法7:setBackgroundColor",
      "设置输入框背景颜色",
      "input.setBackgroundColor(240, 240, 240);"
    );
   
    var bgContainer = new Horizontal();
    bgContainer.setSpacing(10);
   
    var yellowBg = new Input();
    yellowBg.setText("黄色背景");
    yellowBg.setWidth(85);
    yellowBg.setHeight(40);
    yellowBg.setBackgroundColor(255, 255, 200);
    bgContainer.addView(yellowBg);
   
    var cyanBg = new Input();
    cyanBg.setText("青色背景");
    cyanBg.setWidth(85);
    cyanBg.setHeight(40);
    cyanBg.setBackgroundColor(200, 255, 255);
    bgContainer.addView(cyanBg);
   
    var pinkBg = new Input();
    pinkBg.setText("粉色背景");
    pinkBg.setWidth(85);
    pinkBg.setHeight(40);
    pinkBg.setBackgroundColor(255, 220, 230);
    bgContainer.addView(pinkBg);
   
    section7.addView(bgContainer);
    page.addView(section7);
   
    // 方法8&9:setWidth & setHeight - 尺寸设置
    var section8 = createMethodSection(
      "方法8&9:setWidth & setHeight",
      "设置输入框的宽度和高度",
      "input.setWidth(300);\ninput.setHeight(50);"
    );
   
    var sizeContainer = new Vertical();
    sizeContainer.setSpacing(8);
   
    var smallSize = new Input();
    smallSize.setText("小尺寸 (200x35)");
    smallSize.setWidth(200);
    smallSize.setHeight(35);
    smallSize.setBackgroundColor(255, 255, 255);
    sizeContainer.addView(smallSize);
   
    var mediumSize = new Input();
    mediumSize.setText("中尺寸 (250x42)");
    mediumSize.setWidth(250);
    mediumSize.setHeight(42);
    mediumSize.setBackgroundColor(255, 255, 255);
    sizeContainer.addView(mediumSize);
   
    var largeSize = new Input();
    largeSize.setText("大尺寸 (300x50)");
    largeSize.setWidth(300);
    largeSize.setHeight(50);
    largeSize.setBackgroundColor(255, 255, 255);
    sizeContainer.addView(largeSize);
   
    section8.addView(sizeContainer);
    page.addView(section8);
   
    // 添加到TabView
    tab.addView(1, page);
    printl("样式设置页面构建完成");
}

// =============================================================================
// 第三页:高级功能演示
// =============================================================================
function buildAdvancedPage() {
    var page = new Vertical();
    page.setSpacing(0);
    page.setBackgroundColor(245, 250, 245);

    // 方法10:setPlaceholder - 占位符
    var section10 = createMethodSection(
      "方法10:setPlaceholder",
      "设置占位提示文本(输入框为空时显示)",
      "input.setPlaceholder(\"请输入用户名...\");"
    );
   
    var placeholderInput = new Input();
    placeholderInput.setPlaceholder("这是一个占位提示文本...");
    placeholderInput.setWidth(280);
    placeholderInput.setHeight(42);
    placeholderInput.setBackgroundColor(255, 255, 255);
    section10.addView(placeholderInput);
    page.addView(section10);
   
    // 方法11:setTextAlignment - 文本对齐
    var section11 = createMethodSection(
      "方法11:setTextAlignment",
      "设置文本对齐方式 (left/center/right)",
      "input.setTextAlignment(\"center\");"
    );
   
    var alignContainer = new Vertical();
    alignContainer.setSpacing(8);
   
    var leftAlign = new Input();
    leftAlign.setText("左对齐 (left)");
    leftAlign.setTextAlignment("left");
    leftAlign.setWidth(280);
    leftAlign.setHeight(40);
    leftAlign.setBackgroundColor(255, 240, 240);
    alignContainer.addView(leftAlign);
   
    var centerAlign = new Input();
    centerAlign.setText("居中对齐 (center)");
    centerAlign.setTextAlignment("center");
    centerAlign.setWidth(280);
    centerAlign.setHeight(40);
    centerAlign.setBackgroundColor(240, 255, 240);
    alignContainer.addView(centerAlign);
   
    var rightAlign = new Input();
    rightAlign.setText("右对齐 (right)");
    rightAlign.setTextAlignment("right");
    rightAlign.setWidth(280);
    rightAlign.setHeight(40);
    rightAlign.setBackgroundColor(240, 240, 255);
    alignContainer.addView(rightAlign);
   
    section11.addView(alignContainer);
    page.addView(section11);
   
    // 方法12:setInputStyle - 输入框样式
    var section12 = createMethodSection(
      "方法12:setInputStyle",
      "设置输入框样式 (true=底部线条样式)",
      "input.setInputStyle(true); // 底部线条样式"
    );
   
    var styleContainer = new Vertical();
    styleContainer.setSpacing(15);
   
    var normalStyle = new Input();
    normalStyle.setText("普通样式 (默认)");
    normalStyle.setWidth(280);
    normalStyle.setHeight(42);
    normalStyle.setBackgroundColor(255, 255, 255);
    styleContainer.addView(normalStyle);
   
    var lineStyle = new Input();
    lineStyle.setText("底部线条样式");
    lineStyle.setInputStyle(true);
    lineStyle.setWidth(280);
    lineStyle.setHeight(42);
    styleContainer.addView(lineStyle);
   
    section12.addView(styleContainer);
    page.addView(section12);
   
    // 动态样式切换演示
    var sectionDynamic = createMethodSection(
      "动态样式切换",
      "实时修改输入框的各种属性",
      "通过按钮交互动态改变样式"
    );
   
    var dynamicInput = new Input();
    dynamicInput.setText("动态样式输入框");
    dynamicInput.setWidth(280);
    dynamicInput.setHeight(45);
    dynamicInput.setBackgroundColor(255, 255, 255);
    sectionDynamic.addView(dynamicInput);
   
    var btnContainer = new Horizontal();
    btnContainer.setSpacing(8);
   
    var colorBtn = createSmallButton("变色", function() {
      var colors = [
            , , ,
            , ,
      ];
      var randomColor = colors;
      dynamicInput.setBackgroundColor(randomColor, randomColor, randomColor);
      printl("动态样式:背景色已变更");
    });
    btnContainer.addView(colorBtn);
   
    var alignBtn = createSmallButton("切换对齐", function() {
      var aligns = ["left", "center", "right"];
      var currentText = dynamicInput.getText();
      var currentAlign = "left";
      if (currentText.indexOf("居中") !== -1) currentAlign = "center";
      if (currentText.indexOf("右对齐") !== -1) currentAlign = "right";
      
      var nextIndex = (aligns.indexOf(currentAlign) + 1) % 3;
      var nextAlign = aligns;
      
      var alignLabels = { "left": "左对齐", "center": "居中对齐", "right": "右对齐" };
      dynamicInput.setText(alignLabels);
      dynamicInput.setTextAlignment(nextAlign);
      printl("动态样式:对齐方式已切换为 " + nextAlign);
    });
    btnContainer.addView(alignBtn);
   
    var sizeBtn = createSmallButton("调整大小", function() {
      var sizes = [, , ];
      var currentWidth = dynamicInput.getWidth ? 250 : 250; // 默认中尺寸
      var nextSize = sizes;
      dynamicInput.setWidth(nextSize);
      dynamicInput.setHeight(nextSize);
      printl("动态样式:尺寸已调整为 " + nextSize + "x" + nextSize);
    });
    btnContainer.addView(sizeBtn);
   
    sectionDynamic.addView(btnContainer);
    page.addView(sectionDynamic);
   
    // 添加到TabView
    tab.addView(2, page);
    printl("高级功能页面构建完成");
}

// =============================================================================
// 第四页:综合应用演示
// =============================================================================
function buildApplicationPage() {
    var page = new Vertical();
    page.setSpacing(0);
    page.setBackgroundColor(250, 250, 245);

    // 应用场景1:登录表单
    var loginSection = createAppSection("场景1:用户登录表单");
   
    // 用户名输入
    var usernameLabel = new Label();
    usernameLabel.setText("用户名:");
    usernameLabel.setFontSize(14);
    usernameLabel.setTextColor(60, 60, 60);
    loginSection.addView(usernameLabel);
   
    var usernameInput = new Input();
    usernameInput.setID("login_username");
    usernameInput.setPlaceholder("请输入用户名");
    usernameInput.setWidth(280);
    usernameInput.setHeight(42);
    usernameInput.setBackgroundColor(255, 255, 255);
    usernameInput.setTextColor(50, 50, 50);
    loginSection.addView(usernameInput);
   
    // 密码输入
    var passwordLabel = new Label();
    passwordLabel.setText("密码:");
    passwordLabel.setFontSize(14);
    passwordLabel.setTextColor(60, 60, 60);
    loginSection.addView(passwordLabel);
   
    var passwordInput = new Input();
    passwordInput.setID("login_password");
    passwordInput.setPlaceholder("请输入密码");
    passwordInput.setWidth(280);
    passwordInput.setHeight(42);
    passwordInput.setBackgroundColor(255, 255, 255);
    passwordInput.setInputStyle(true); // 使用底部线条样式
    loginSection.addView(passwordInput);
   
    // 登录结果标签
    var loginResult = createResultLabel("等待操作...");
    loginSection.addView(loginResult);
   
    // 按钮区域
    var loginBtnContainer = new Horizontal();
    loginBtnContainer.setSpacing(15);
   
    var loginBtn = createActionButton("登录", function() {
      var username = usernameInput.getText();
      var password = passwordInput.getText();
      
      if (username === "" || password === "") {
            loginResult.setText("❌ 请填写完整信息!");
            loginResult.setTextColor(255, 0, 0);
      } else {
            loginResult.setText("✅ 登录成功!欢迎 " + username);
            loginResult.setTextColor(0, 150, 0);
            printl("登录演示:用户名=" + username + ", 密码长度=" + password.length);
      }
    });
    loginBtnContainer.addView(loginBtn);
   
    var resetBtn = createSecondaryButton("重置", function() {
      usernameInput.setText("");
      passwordInput.setText("");
      loginResult.setText("已重置,请重新输入");
      loginResult.setTextColor(100, 100, 100);
      printl("登录演示:表单已重置");
    });
    loginBtnContainer.addView(resetBtn);
   
    loginSection.addView(loginBtnContainer);
    page.addView(loginSection);
   
    // 应用场景2:个人信息编辑
    var profileSection = createAppSection("场景2:个人信息编辑");
   
    // 昵称
    var nicknameRow = createInputRow("昵称", "nickname_field", "请输入昵称");
    profileSection.addView(nicknameRow);
   
    // 邮箱
    var emailRow = createInputRow("邮箱", "email_field", "请输入邮箱地址");
    profileSection.addView(emailRow);
   
    // 电话
    var phoneRow = createInputRow("电话", "phone_field", "请输入电话号码");
    profileSection.addView(phoneRow);
   
    // 保存按钮
    var saveBtn = createActionButton("保存信息", function() {
      var nickname = config.getConfig("nickname_field");
      var email = config.getConfig("email_field");
      var phone = config.getConfig("phone_field");
      
      printl("保存信息:昵称=" + nickname + ", 邮箱=" + email + ", 电话=" + phone);
      
      var saveResult = createResultLabel("✅ 信息已保存到配置!");
      saveResult.setTextColor(0, 150, 0);
      profileSection.addView(saveResult);
      
      // 3秒后移除结果提示
      sleep(3000);
      // 注意:实际应用中可能需要使用定时器
    });
    profileSection.addView(saveBtn);
   
    page.addView(profileSection);
   
    // 应用场景3:搜索功能
    var searchSection = createAppSection("场景3:搜索功能");
   
    var searchContainer = new Horizontal();
    searchContainer.setSpacing(10);
   
    var searchInput = new Input();
    searchInput.setPlaceholder("请输入搜索关键词...");
    searchInput.setWidth(200);
    searchInput.setHeight(42);
    searchInput.setBackgroundColor(255, 255, 255);
    searchInput.setTextAlignment("left");
    searchContainer.addView(searchInput);
   
    var searchBtn = new Button();
    searchBtn.setText("🔍 搜索");
    searchBtn.setColor(0, 122, 255);
    searchBtn.setTextColor(255, 255, 255);
    searchBtn.setWidth(80);
    searchBtn.setHeight(42);
   
    var searchResult = createResultLabel("输入关键词后点击搜索");
   
    searchBtn.onClick(function() {
      var keyword = searchInput.getText();
      if (keyword === "") {
            searchResult.setText("⚠️ 请输入搜索关键词");
            searchResult.setTextColor(255, 150, 0);
      } else {
            searchResult.setText("🔍 正在搜索: \"" + keyword + "\"...");
            searchResult.setTextColor(0, 100, 200);
            printl("搜索演示:关键词=\"" + keyword + "\"");
      }
    });
    searchContainer.addView(searchBtn);
   
    searchSection.addView(searchContainer);
    searchSection.addView(searchResult);
    page.addView(searchSection);
   
    // 添加到TabView
    tab.addView(3, page);
    printl("综合应用页面构建完成");
}

// =============================================================================
// 第五页:关于页面
// =============================================================================
function buildAboutPage() {
    var page = new Vertical();
    page.setSpacing(0);
    page.setBackgroundColor(240, 248, 255);
    page.setAlignment("center");

    // 应用图标区域(使用Label模拟)
    var iconLabel = new Label();
    iconLabel.setText("⌨️");
    iconLabel.setFontSize(40);
    page.addView(iconLabel);
   
    // 标题
    var appTitle = new Label();
    appTitle.setText("Input控件系统化示例");
    appTitle.setFontSize(22);
    appTitle.setTextColor(0, 100, 150);
    appTitle.setTextAlignment("center");
    page.addView(appTitle);
   
    // 版本信息
    var versionLabel = new Label();
    versionLabel.setText("版本: 2.0.0");
    versionLabel.setFontSize(14);
    versionLabel.setTextColor(100, 100, 100);
    versionLabel.setTextAlignment("center");
    page.addView(versionLabel);
   
    // 分隔线
    var line = new Label();
    line.setText("━━━━━━━━━━━━━━━━");
    line.setTextAlignment("center");
    line.setTextColor(200, 200, 200);
    page.addView(line);
   
    // 方法列表
    var methodListLabel = new Label();
    methodListLabel.setText("📋 Input控件方法清单");
    methodListLabel.setFontSize(16);
    methodListLabel.setTextColor(50, 50, 50);
    methodListLabel.setTextAlignment("center");
    page.addView(methodListLabel);
   
    var methodsInfo = new Label();
    methodsInfo.setText(
      "1. setText(text) - 设置文本\n" +
      "2. getText() - 获取文本\n" +
      "3. setID(id) - 设置控件ID\n" +
      "4. setDefultText(text) - 设置默认文本\n" +
      "5. setTextColor(r,g,b) - 设置文本颜色\n" +
      "6. setFontSize(size) - 设置字体大小\n" +
      "7. setBackgroundColor(r,g,b) - 设置背景色\n" +
      "8. setWidth(width) - 设置宽度\n" +
      "9. setHeight(height) - 设置高度\n" +
      "10. setPlaceholder(text) - 设置占位符\n" +
      "11. setTextAlignment(align) - 设置对齐\n" +
      "12. setInputStyle(bool) - 设置样式"
    );
    methodsInfo.setFontSize(11);
    methodsInfo.setTextColor(80, 80, 80);
    methodsInfo.setTextAlignment("left");
    methodsInfo.setBackgroundColor(255, 255, 255);
    methodsInfo.setWidth(300);
    methodsInfo.setHeight(180);
    page.addView(methodsInfo);
   
    // 分隔线
    var line2 = new Label();
    line2.setText("━━━━━━━━━━━━━━━━");
    line2.setTextAlignment("center");
    line2.setTextColor(200, 200, 200);
    page.addView(line2);
   

   
    // 退出按钮
    var exitBtn = new Button();
    exitBtn.setText("退出示例");
    exitBtn.setColor(255, 59, 48);
    exitBtn.setTextColor(255, 255, 255);
    exitBtn.setWidth(150);
    exitBtn.setHeight(45);
    exitBtn.onClick(function() {
      printl("用户退出示例");
      tab.dismiss();
    });
    page.addView(exitBtn);
   
    // 添加到TabView
    tab.addView(4, page);
    printl("关于页面构建完成");
}

// =============================================================================
// 辅助函数 - UI组件创建
// =============================================================================

// 创建章节标题
function createSectionTitle(text) {
    var title = new Label();
    title.setText(text);
    title.setFontSize(18);
    title.setTextColor(0, 100, 150);
    title.setTextAlignment("center");
    title.setWidth(350);
    title.setHeight(30);
    return title;
}

// 创建方法演示区块
function createMethodSection(methodName, description, codeExample) {
    var section = new Vertical();
    section.setSpacing(0);
    section.setBackgroundColor(255, 255, 255);
   
    // 方法名称
    var nameLabel = new Label();
    nameLabel.setText(methodName);
    nameLabel.setFontSize(15);
    nameLabel.setTextColor(0, 122, 255);
    nameLabel.setTextAlignment("left");
    section.addView(nameLabel);
   
    // 方法描述
    var descLabel = new Label();
    descLabel.setText(description);
    descLabel.setFontSize(12);
    descLabel.setTextColor(80, 80, 80);
    section.addView(descLabel);
   
    // 代码示例
    var codeLabel = new Label();
    codeLabel.setText(codeExample);
    codeLabel.setFontSize(11);
    codeLabel.setTextColor(50, 50, 150);
    codeLabel.setBackgroundColor(245, 245, 255);
    codeLabel.setWidth(280);
    codeLabel.setHeight(35);
    section.addView(codeLabel);
   
    return section;
}

// 创建应用场景区块
function createAppSection(title) {
    var section = new Vertical();
    section.setSpacing(2);
    section.setBackgroundColor(255, 255, 255);
   
    var titleLabel = new Label();
    titleLabel.setText(title);
    titleLabel.setFontSize(16);
    titleLabel.setTextColor(80, 80, 80);
    section.addView(titleLabel);
   
    return section;
}

// 创建输入行(标签+输入框)
function createInputRow(labelText, inputId, placeholder) {
    var row = new Vertical();
    row.setSpacing(5);
   
    var label = new Label();
    label.setText(labelText + ":");
    label.setFontSize(13);
    label.setTextColor(60, 60, 60);
    row.addView(label);
   
    var input = new Input();
    input.setID(inputId);
    input.setPlaceholder(placeholder);
    input.setWidth(280);
    input.setHeight(40);
    input.setBackgroundColor(250, 250, 250);
    row.addView(input);
   
    return row;
}

// 创建操作按钮
function createActionButton(text, onClickHandler) {
    var btn = new Button();
    btn.setText(text);
    btn.setColor(0, 122, 255);
    btn.setTextColor(255, 255, 255);
    btn.setWidth(120);
    btn.setHeight(40);
    btn.onClick(onClickHandler);
    return btn;
}

// 创建次要按钮
function createSecondaryButton(text, onClickHandler) {
    var btn = new Button();
    btn.setText(text);
    btn.setColor(150, 150, 150);
    btn.setTextColor(255, 255, 255);
    btn.setWidth(100);
    btn.setHeight(40);
    btn.onClick(onClickHandler);
    return btn;
}

// 创建小按钮
function createSmallButton(text, onClickHandler) {
    var btn = new Button();
    btn.setText(text);
    btn.setColor(100, 150, 200);
    btn.setTextColor(255, 255, 255);
    btn.setWidth(85);
    btn.setHeight(35);
    btn.onClick(onClickHandler);
    return btn;
}

// 创建结果标签
function createResultLabel(text) {
    var label = new Label();
    label.setText(text);
    label.setFontSize(12);
    label.setTextColor(100, 100, 100);
    label.setBackgroundColor(245, 245, 245);
    label.setWidth(280);
    label.setHeight(30);
    return label;
}

// 创建信息标签
function createInfoLabel(text) {
    var label = new Label();
    label.setText(text);
    label.setFontSize(11);
    label.setTextColor(120, 120, 120);
    label.setTextAlignment("center");
    return label;
}

// =============================================================================
// 程序入口
// =============================================================================
printl("=== Input控件全新系统化示例已启动 ===");
printl("本示例包含5个Tab页面,全面展示Input控件的12个方法");


页: [1]
查看完整版本: AIWROK苹果脚本实例1界面UI输入框类[Input]