AIWROKÈí¼þÆ»¹ûIOSÀïµÄUI-ÊäÈë¿òÀà[Input]·½·¨Ð¡½á
- //🍎UI-ÊäÈë¿òÀà[Input]·½·¨·½·¨Ð¡½á£¬½»Á÷QQȺ711841924
- //µÚÒ»¸ö·½·¨£º📌setText ÉèÖÃÊäÈë¿òÎı¾
- var input = new Input();
- input.setText("Hello"); // ÉèÖÃÊäÈë¿òÎı¾ÎªHello
- //µÚ¶þ¸ö·½·¨£º📌getText »ñÈ¡ÊäÈë¿òÎı¾
- var input = new Input();
- string currentText = input.getText(); // »ñÈ¡ÊäÈë¿òµÄÎı¾ÄÚÈÝ
- //µÚÈý¸ö·½·¨£º📌setlDÉèÖÿؼþID
- var input = new Input();
- input.setID("input123");
- //¶ÁȡʹÓÃ
- config.getConfig("input123");
- //µÚËĸö·½·¨£º📌setDefultText ÉèÖÃĬÈÏÖµ
- var input = new Input();
- input.setID("ÊäÈë¿ò1")
- input.setDefultText("Hello"); // ÉèÖÃÊäÈë¿òÎı¾ÎªHello
- //µÚÎå¸ö·½·¨£º📌setTextColorÉèÖÃÎı¾ÑÕÉ«
- var input = new Input();
- input.setTextColor(255, 0, 0); // ÉèÖÃÎı¾ÑÕɫΪºìÉ«
- //µÚÁù¸ö·½·¨£º📌setFontSizeÉèÖÃ×ÖÌå´óС
- var input = new Input();
- input.setFontSize(14); // ÉèÖÃ×ÖÌå´óСΪ14
- //µÚÆß¸ö·½·¨£º📌setBackgroundColor ÉèÖñ³¾°ÑÕÉ«
- var input = new Input();
- input.setBackgroundColor(0, 255, 0); // ÉèÖñ³¾°ÑÕɫΪÂÌÉ«
- //µÚ°Ë¸ö·½·¨£º📌setWidthÉèÖÃÊäÈë¿ò¿í¶È
- var input = new Input();
- input.setWidth(300); // ÉèÖÃÊäÈë¿ò¿í¶ÈΪ300
- //µÚ¾Å¸ö·½·¨£º📌setHeight ÉèÖÃÊäÈë¿ò¸ß¶È
- var input = new Input();
- input.setHeight(40); // ÉèÖÃÊäÈë¿ò¸ß¶ÈΪ40
- //µÚÊ®¸ö·½·¨£º📌setPlaceholder ÉèÖÃռλ·ûÎı¾
- var input = new Input();
- input.setPlaceholder("ÇëÊäÈëÄÚÈÝ"); // ÉèÖÃռλ·ûÎı¾Îª'ÇëÊäÈëÄÚÈÝ'
- //µÚʮһ¸ö·½·¨£º📌setTextAlignment ÉèÖÃÎı¾¶ÔÆë·½Ê½
- var input = new Input();
- input.setTextAlignment("center"); // ÉèÖÃÎı¾¶ÔÆë·½Ê½Îª¾ÓÖÐ
- //µÚÊ®¶þ¸ö·½·¨£º📌setlnputStyleÉèÖÃÊäÈë¿òÑùʽ
- var input = new Input();
- input.setInputStyle(true); // ÉèÖÃÊäÈë¿òÑùʽΪµ×²¿ÏßÌõ
¸´ÖÆ´úÂë
📌setText ÉèÖÃÊäÈë¿òÎı¾ Àà±ð
| ÏêÇé˵Ã÷
| ·½·¨¹¦ÄÜ
| ÉèÖÃÊäÈë¿òµÄÏÔʾÎı¾
| ·½·¨Ç©Ãû
| Void setText(String text)
| ·µ»ØÖµ
| Void
| ²ÎÊý
| -String text
£ºÒªÉèÖõÄÊäÈë¿òÎı¾ÄÚÈÝ
| °¸Àý
| var input = new Input();
input.setText("Hello"); // ÉèÖÃÊäÈë¿òÎı¾ÎªHello
|
📌getText »ñÈ¡ÊäÈë¿òÎı¾ Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | »ñÈ¡µ±Ç°ÊäÈë¿òµÄÎı¾ÄÚÈÝ | ·½·¨Ç©Ãû | String getText() | ·µ»ØÖµ | String | ²ÎÊý | ÎÞ | °¸Àý | var input = new Input(); string currentText = input.getText(); // »ñÈ¡ÊäÈë¿òµÄÎı¾ÄÚÈÝ |
📌setlDÉèÖÿؼþID
Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÿؼþ ID£¬ÉèÖúó¿É×Ô¶¯±£´æÅäÖÃÐÅÏ¢ | ·½·¨Ç©Ãû | Void setID(String id) | ·µ»ØÖµ | Void | ²ÎÊý | - String id £ºÒªÉèÖõĿؼþ ID | °¸Àý | var input = new Input(); input.setID("input123"); //¶ÁȡʹÓà config.getConfig("input123"); |
📌setDefultText ÉèÖÃĬÈÏÖµ Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃÊäÈë¿òµÄĬÈÏÏÔʾÎı¾ | ·½·¨Ç©Ãû | Void setDefaultText(String text) | ·µ»ØÖµ | Void | ²ÎÊý | - String text £ºÒªÉèÖõÄÊäÈë¿òĬÈÏÎı¾ÄÚÈÝ | °¸Àý | var input = new Input(); input.setID("ÊäÈë¿ò1") input.setDefultText("Hello"); // ÉèÖÃÊäÈë¿òÎı¾ÎªHello |
📌setTextColorÉèÖÃÎı¾ÑÕÉ« Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃÊäÈë¿òÎı¾µÄÑÕÉ« | ·½·¨Ç©Ãû | Void setTextColor(Int32 red, Int32 green, Int32 blue) | ·µ»ØÖµ | Void | ²ÎÊý | - Int32 red £ººìÉ«·ÖÁ¿£¨Í¨³£È¡Öµ·¶Î§ 0~255 £©
- Int32 green £ºÂÌÉ«·ÖÁ¿£¨Í¨³£È¡Öµ·¶Î§ 0~255 £©
- Int32 blue £ºÀ¶É«·ÖÁ¿£¨Í¨³£È¡Öµ·¶Î§ 0~255 £© | °¸Àý | var input = new Input(); input.setTextColor(255, 0, 0); // ÉèÖÃÎı¾ÑÕɫΪºìÉ« |
📌setFontSizeÉèÖÃ×ÖÌå´óС Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃÊäÈë¿òÖÐÎı¾µÄ×ÖÌå´óС | ·½·¨Ç©Ãû | Void setFontSize(Int32 size) | ·µ»ØÖµ | Void | ²ÎÊý | - Int32 size £ºÒªÉèÖõÄ×ÖÌå´óС | °¸Àý | var input = new Input(); input.setFontSize(14); // ÉèÖÃ×ÖÌå´óСΪ14 |
📌setBackgroundColor ÉèÖñ³¾°ÑÕÉ« Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃÊäÈë¿òµÄ±³¾°ÑÕÉ« | ·½·¨Ç©Ãû | Void setBackgroundColor(Int32 red, Int32 green, Int32 blue) | ·µ»ØÖµ | Void | ²ÎÊý | - Int32 red £ººìÉ«·ÖÁ¿£¨Í¨³£È¡Öµ·¶Î§ 0~255 £©
- Int32 green £ºÂÌÉ«·ÖÁ¿£¨Í¨³£È¡Öµ·¶Î§ 0~255 £©
- Int32 blue £ºÀ¶É«·ÖÁ¿£¨Í¨³£È¡Öµ·¶Î§ 0~255 £© | °¸Àý | var input = new Input(); input.setBackgroundColor(0, 255, 0); // ÉèÖñ³¾°ÑÕɫΪÂÌÉ« |
📌setWidthÉèÖÃÊäÈë¿ò¿í¶È Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃÊäÈë¿òµÄ¿í¶È | ·½·¨Ç©Ãû | Void setWidth(Int32 width) | ·µ»ØÖµ | Void | ²ÎÊý | - Int32 width £ºÒªÉèÖõÄÊäÈë¿ò¿í¶È | °¸Àý | var input = new Input(); input.setWidth(300); // ÉèÖÃÊäÈë¿ò¿í¶ÈΪ300 |
📌setHeight ÉèÖÃÊäÈë¿ò¸ß¶È Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃÊäÈë¿òµÄ¸ß¶È | ·½·¨Ç©Ãû | Void setHeight(Int32 height) | ·µ»ØÖµ | Void | ²ÎÊý | - Int32 height £ºÒªÉèÖõÄÊäÈë¿ò¸ß¶È | °¸Àý | var input = new Input(); input.setHeight(40); // ÉèÖÃÊäÈë¿ò¸ß¶ÈΪ40 |
📌setPlaceholder ÉèÖÃռλ·ûÎı¾ Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃÊäÈë¿òµÄռλ·ûÎı¾ | ·½·¨Ç©Ãû | Void setPlaceholder(String text) | ·µ»ØÖµ | Void | ²ÎÊý | - String text £ºÒªÉèÖõÄռλ·ûÎı¾ÄÚÈÝ | °¸Àý | var input = new Input(); input.setPlaceholder("ÇëÊäÈëÄÚÈÝ"); // ÉèÖÃռλ·ûÎı¾Îª'ÇëÊäÈëÄÚÈÝ' |
📌setTextAlignment ÉèÖÃÎı¾¶ÔÆë·½Ê½ Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃÊäÈë¿òÖÐÎÄ×ÖµÄ¶ÔÆë·½Ê½ | ·½·¨Ç©Ãû | Void setTextAlignment(String alignment) | ·µ»ØÖµ | Void | ²ÎÊý | - String alignment £ºÎı¾¶ÔÆë·½Ê½£¨Èç center ¡¢left ¡¢right µÈ¿Éѡֵ£© | °¸Àý | var input = new Input(); input.setTextAlignment("center"); // ÉèÖÃÎı¾¶ÔÆë·½Ê½Îª¾ÓÖÐ |
📌setlnputStyleÉèÖÃÊäÈë¿òÑùʽ Àà±ð | ÏêÇé˵Ã÷ | ·½·¨¹¦ÄÜ | ÉèÖÃÊäÈë¿òµÄÏÔʾÎı¾ | ·½·¨Ç©Ãû | Void setText(String text) | ·µ»ØÖµ | Void | ²ÎÊý | - String text £ºÒªÉèÖõÄÊäÈë¿òÎı¾ÄÚÈÝ | °¸Àý | var input = new Input(); input.setInputStyle(true); // ÉèÖÃÊäÈë¿òÑùʽΪµ×²¿ÏßÌõ |
ÍêÕû°¸Àý£º - // 🔨UI-ÊäÈë¿òÀà[Input]·½·¨ÍêÕûʾÀý
- // 🍎UI-ÊäÈë¿òÀà[Input]·½·¨Ð¡½á£¬½»Á÷QQȺ711841924
- printl("=== Input¿Ø¼þ·½·¨ÍêÕûʾÀý ===");
- var vc = new IOSView();
- vc.show(() => {
- printl("InputʾÀý½çÃæÒѼÓÔØ");
-
- // »ñÈ¡µ±Ç°ÊÓͼ
- var view = vc.getView();
-
- // ´´½¨Ö÷ÈÝÆ÷
- var mainContainer = new Vertical();
- mainContainer.setSpacing(15);
- mainContainer.setBackgroundColor(245, 245, 245);
-
- // ±êÌâÇøÓò
- var titleContainer = new Vertical();
- titleContainer.setAlignment("center");
- titleContainer.setSpacing(5);
- titleContainer.setBackgroundColor(0, 122, 255);
-
- var titleLabel = new Label();
- titleLabel.setText("Input¿Ø¼þÑÝʾ");
- titleLabel.setFontSize(20.0);
- titleLabel.setTextColor(255, 255, 255);
- titleLabel.setTextAlignment("center");
-
- var subtitleLabel = new Label();
- subtitleLabel.setText("ÊäÈë¿ò¿Ø¼þµÄʹÓ÷½·¨");
- subtitleLabel.setFontSize(14.0);
- subtitleLabel.setTextColor(255, 255, 255);
- subtitleLabel.setTextAlignment("center");
-
- titleContainer.addView(titleLabel);
- titleContainer.addView(subtitleLabel);
- mainContainer.addView(titleContainer);
-
- // Input·½·¨ÑÝÊ¾ÇøÓò
- var demoContainer = new Vertical();
- demoContainer.setBackgroundColor(255, 255, 255);
- demoContainer.setSpacing(15);
-
- var demoTitle = new Label();
- demoTitle.setText("Input¿Ø¼þ¹¦ÄÜÑÝʾ");
- demoTitle.setFontSize(16.0);
- demoTitle.setTextColor(0, 0, 0);
- demoTitle.setTextAlignment("center");
- demoContainer.addView(demoTitle);
-
- // µÚÒ»¸ö·½·¨£ºsetText ÉèÖÃÊäÈë¿òÎı¾
- var setTextDemo = new Vertical();
- setTextDemo.setSpacing(5);
-
- var setTextLabel = new Label();
- setTextLabel.setText("📌 setText ÉèÖÃÊäÈë¿òÎı¾");
- setTextLabel.setFontSize(14.0);
- setTextLabel.setTextColor(0, 122, 255);
- setTextDemo.addView(setTextLabel);
-
- var setInput = new Input();
- setInput.setText("Hello"); // ÉèÖÃÊäÈë¿òÎı¾ÎªHello
- setInput.setWidth(250);
- setInput.setHeight(40);
- setInput.setBackgroundColor(240, 240, 240);
-
- setTextDemo.addView(setInput);
- demoContainer.addView(setTextDemo);
-
- // µÚ¶þ¸ö·½·¨£ºgetText »ñÈ¡ÊäÈë¿òÎı¾
- var getTextDemo = new Vertical();
- getTextDemo.setSpacing(5);
-
- var getTextLabel = new Label();
- getTextLabel.setText("📌 getText »ñÈ¡ÊäÈë¿òÎı¾");
- getTextLabel.setFontSize(14.0);
- getTextLabel.setTextColor(0, 122, 255);
- getTextDemo.addView(getTextLabel);
-
- var getInput = new Input();
- getInput.setPlaceholder("ÇëÊäÈëÄÚÈÝ");
- getInput.setWidth(250);
- getInput.setHeight(40);
- getInput.setBackgroundColor(240, 240, 240);
-
- var getButton = new Button();
- getButton.setText("»ñÈ¡Îı¾");
- getButton.setColor(52, 199, 89);
- getButton.setTextColor(255, 255, 255);
- getButton.setWidth(80);
- getButton.setHeight(40);
-
- getButton.onClick(() => {
- var currentText = getInput.getText(); // »ñÈ¡ÊäÈë¿òµÄÎı¾ÄÚÈÝ
- printl("ÊäÈë¿òÄÚÈÝ: " + currentText);
-
- var resultLabel = new Label();
- resultLabel.setText("»ñÈ¡µ½: " + currentText);
- resultLabel.setFontSize(12.0);
- resultLabel.setTextColor(52, 199, 89);
- getTextDemo.addView(resultLabel);
- });
-
- var getTextContainer = new Horizontal();
- getTextContainer.setSpacing(10);
- getTextContainer.addView(getInput);
- getTextContainer.addView(getButton);
-
- getTextDemo.addView(getTextContainer);
- demoContainer.addView(getTextDemo);
-
- // µÚÈý¸ö·½·¨ºÍµÚËĸö·½·¨£ºsetID ºÍ setDefultText
- var idDefaultDemo = new Vertical();
- idDefaultDemo.setSpacing(5);
-
- var idDefaultLabel = new Label();
- idDefaultLabel.setText("📌 setID ºÍ setDefultText");
- idDefaultLabel.setFontSize(14.0);
- idDefaultLabel.setTextColor(0, 122, 255);
- idDefaultDemo.addView(idDefaultLabel);
-
- var idInput = new Input();
- idInput.setID("ÊäÈë¿ò1");
- idInput.setDefultText("Hello"); // ÉèÖÃÊäÈë¿òĬÈÏÎı¾ÎªHello
- idInput.setWidth(250);
- idInput.setHeight(40);
- idInput.setBackgroundColor(240, 240, 240);
-
- var idButton = new Button();
- idButton.setText("¶ÁÈ¡ÅäÖÃ");
- idButton.setColor(255, 149, 0);
- idButton.setTextColor(255, 255, 255);
- idButton.setWidth(80);
- idButton.setHeight(40);
-
- idButton.onClick(() => {
- var savedConfig = config.getConfig("ÊäÈë¿ò1");
- printl("±£´æµÄÅäÖÃ: " + savedConfig);
-
- var resultLabel = new Label();
- resultLabel.setText("ÅäÖÃÖµ: " + savedConfig);
- resultLabel.setFontSize(12.0);
- resultLabel.setTextColor(255, 149, 0);
- idDefaultDemo.addView(resultLabel);
- });
-
- var idContainer = new Horizontal();
- idContainer.setSpacing(10);
- idContainer.addView(idInput);
- idContainer.addView(idButton);
-
- idDefaultDemo.addView(idContainer);
- demoContainer.addView(idDefaultDemo);
-
- // µÚÎå¸ö·½·¨£ºsetTextColorÉèÖÃÎı¾ÑÕÉ«
- var textColorDemo = new Vertical();
- textColorDemo.setSpacing(5);
-
- var textColorLabel = new Label();
- textColorLabel.setText("📌 setTextColorÉèÖÃÎı¾ÑÕÉ«");
- textColorLabel.setFontSize(14.0);
- textColorLabel.setTextColor(0, 122, 255);
- textColorDemo.addView(textColorLabel);
-
- var colorInput = new Input();
- colorInput.setPlaceholder("ºìÉ«Îı¾ÊäÈë¿ò");
- colorInput.setTextColor(255, 0, 0); // ÉèÖÃÎı¾ÑÕɫΪºìÉ«
- colorInput.setWidth(250);
- colorInput.setHeight(40);
- colorInput.setBackgroundColor(240, 240, 240);
-
- textColorDemo.addView(colorInput);
- demoContainer.addView(textColorDemo);
-
- // µÚÁù¸ö·½·¨£ºsetFontSizeÉèÖÃ×ÖÌå´óС
- var fontSizeDemo = new Vertical();
- fontSizeDemo.setSpacing(5);
-
- var fontSizeLabel = new Label();
- fontSizeLabel.setText("📌 setFontSizeÉèÖÃ×ÖÌå´óС");
- fontSizeLabel.setFontSize(14.0);
- fontSizeLabel.setTextColor(0, 122, 255);
- fontSizeDemo.addView(fontSizeLabel);
-
- var sizeInput = new Input();
- sizeInput.setPlaceholder("´ó×ÖÌåÊäÈë¿ò");
- sizeInput.setFontSize(18); // ÉèÖÃ×ÖÌå´óСΪ18
- sizeInput.setWidth(250);
- sizeInput.setHeight(40);
- sizeInput.setBackgroundColor(240, 240, 240);
-
- fontSizeDemo.addView(sizeInput);
- demoContainer.addView(fontSizeDemo);
-
- // µÚÆß¸ö·½·¨£ºsetBackgroundColor ÉèÖñ³¾°ÑÕÉ«
- var bgColorDemo = new Vertical();
- bgColorDemo.setSpacing(5);
-
- var bgColorLabel = new Label();
- bgColorLabel.setText("📌 setBackgroundColorÉèÖñ³¾°ÑÕÉ«");
- bgColorLabel.setFontSize(14.0);
- bgColorLabel.setTextColor(0, 122, 255);
- bgColorDemo.addView(bgColorLabel);
-
- var bgInput = new Input();
- bgInput.setPlaceholder("ÂÌÉ«±³¾°ÊäÈë¿ò");
- bgInput.setBackgroundColor(144, 238, 144); // ÉèÖñ³¾°ÑÕɫΪdzÂÌÉ«
- bgInput.setWidth(250);
- bgInput.setHeight(40);
-
- bgColorDemo.addView(bgInput);
- demoContainer.addView(bgColorDemo);
-
- // µÚ°Ë¸öºÍµÚ¾Å¸ö·½·¨£ºsetWidth ºÍ setHeight
- var sizeDemo = new Vertical();
- sizeDemo.setSpacing(5);
-
- var sizeLabel = new Label();
- sizeLabel.setText("📌 setWidth ºÍ setHeight");
- sizeLabel.setFontSize(14.0);
- sizeLabel.setTextColor(0, 122, 255);
- sizeDemo.addView(sizeLabel);
-
- var sizeInput = new Input();
- sizeInput.setPlaceholder("×Ô¶¨Òå³ß´çÊäÈë¿ò");
- sizeInput.setWidth(300); // ÉèÖÃÊäÈë¿ò¿í¶ÈΪ300
- sizeInput.setHeight(50); // ÉèÖÃÊäÈë¿ò¸ß¶ÈΪ50
- sizeInput.setBackgroundColor(240, 240, 240);
-
- sizeDemo.addView(sizeInput);
- demoContainer.addView(sizeDemo);
-
- // µÚÊ®¸ö·½·¨£ºsetPlaceholder ÉèÖÃռλ·ûÎı¾
- var placeholderDemo = new Vertical();
- placeholderDemo.setSpacing(5);
-
- var placeholderLabel = new Label();
- placeholderLabel.setText("📌 setPlaceholder ÉèÖÃռλ·ûÎı¾");
- placeholderLabel.setFontSize(14.0);
- placeholderLabel.setTextColor(0, 122, 255);
- placeholderDemo.addView(placeholderLabel);
-
- var placeholderInput = new Input();
- placeholderInput.setPlaceholder("ÇëÊäÈëÄÚÈÝ"); // ÉèÖÃռλ·ûÎı¾Îª'ÇëÊäÈëÄÚÈÝ'
- placeholderInput.setWidth(250);
- placeholderInput.setHeight(40);
- placeholderInput.setBackgroundColor(240, 240, 240);
-
- placeholderDemo.addView(placeholderInput);
- demoContainer.addView(placeholderDemo);
-
- // µÚʮһ¸ö·½·¨£ºsetTextAlignment ÉèÖÃÎı¾¶ÔÆë·½Ê½
- var alignmentDemo = new Vertical();
- alignmentDemo.setSpacing(5);
-
- var alignmentLabel = new Label();
- alignmentLabel.setText("📌 setTextAlignment ÉèÖÃÎı¾¶ÔÆë·½Ê½");
- alignmentLabel.setFontSize(14.0);
- alignmentLabel.setTextColor(0, 122, 255);
- alignmentDemo.addView(alignmentLabel);
-
- var leftInput = new Input();
- leftInput.setPlaceholder("×ó¶ÔÆë");
- leftInput.setTextAlignment("left"); // ÉèÖÃÎı¾¶ÔÆë·½Ê½Îª×ó¶ÔÆë
- leftInput.setWidth(250);
- leftInput.setHeight(40);
- leftInput.setBackgroundColor(240, 240, 240);
-
- var centerInput = new Input();
- centerInput.setPlaceholder("¾ÓÖÐ¶ÔÆë");
- centerInput.setTextAlignment("center"); // ÉèÖÃÎı¾¶ÔÆë·½Ê½Îª¾ÓÖÐ
- centerInput.setWidth(250);
- centerInput.setHeight(40);
- centerInput.setBackgroundColor(240, 240, 240);
-
- var rightInput = new Input();
- rightInput.setPlaceholder("ÓÒ¶ÔÆë");
- rightInput.setTextAlignment("right"); // ÉèÖÃÎı¾¶ÔÆë·½Ê½ÎªÓÒ¶ÔÆë
- rightInput.setWidth(250);
- rightInput.setHeight(40);
- rightInput.setBackgroundColor(240, 240, 240);
-
- alignmentDemo.addView(leftInput);
- alignmentDemo.addView(centerInput);
- alignmentDemo.addView(rightInput);
- demoContainer.addView(alignmentDemo);
-
- // µÚÊ®¶þ¸ö·½·¨£ºsetInputStyleÉèÖÃÊäÈë¿òÑùʽ
- var styleDemo = new Vertical();
- styleDemo.setSpacing(5);
-
- var styleLabel = new Label();
- styleLabel.setText("📌 setInputStyleÉèÖÃÊäÈë¿òÑùʽ");
- styleLabel.setFontSize(14.0);
- styleLabel.setTextColor(0, 122, 255);
- styleDemo.addView(styleLabel);
-
- var styleInput = new Input();
- styleInput.setPlaceholder("µ×²¿ÏßÌõÑùʽ");
- styleInput.setInputStyle(true); // ÉèÖÃÊäÈë¿òÑùʽΪµ×²¿ÏßÌõ
- styleInput.setWidth(250);
- styleInput.setHeight(40);
-
- styleDemo.addView(styleInput);
- demoContainer.addView(styleDemo);
-
- mainContainer.addView(demoContainer);
-
- // ʵ¼ÊÓ¦ÓÃʾÀý
- var applicationContainer = new Vertical();
- applicationContainer.setBackgroundColor(255, 255, 255);
- applicationContainer.setSpacing(15);
-
- var appTitle = new Label();
- appTitle.setText("Inputʵ¼ÊÓ¦ÓÃʾÀý");
- appTitle.setFontSize(16.0);
- appTitle.setTextColor(0, 0, 0);
- appTitle.setTextAlignment("center");
- applicationContainer.addView(appTitle);
-
- // Óû§ÃûÊäÈë
- var usernameContainer = new Vertical();
- usernameContainer.setSpacing(5);
-
- var usernameLabel = new Label();
- usernameLabel.setText("Óû§Ãû:");
- usernameLabel.setFontSize(14.0);
- usernameLabel.setTextColor(0, 0, 0);
- usernameContainer.addView(usernameLabel);
-
- var usernameInput = new Input();
- usernameInput.setPlaceholder("ÇëÊäÈëÓû§Ãû");
- usernameInput.setWidth(250);
- usernameInput.setHeight(40);
- usernameInput.setBackgroundColor(240, 240, 240);
- usernameContainer.addView(usernameInput);
- applicationContainer.addView(usernameContainer);
-
- // ÃÜÂëÊäÈë
- var passwordContainer = new Vertical();
- passwordContainer.setSpacing(5);
-
- var passwordLabel = new Label();
- passwordLabel.setText("ÃÜÂë:");
- passwordLabel.setFontSize(14.0);
- passwordLabel.setTextColor(0, 0, 0);
- passwordContainer.addView(passwordLabel);
-
- var passwordInput = new Input();
- passwordInput.setPlaceholder("ÇëÊäÈëÃÜÂë");
- passwordInput.setWidth(250);
- passwordInput.setHeight(40);
- passwordInput.setBackgroundColor(240, 240, 240);
- passwordInput.setInputStyle(true); // µ×²¿ÏßÌõÑùʽ
- passwordContainer.addView(passwordInput);
- applicationContainer.addView(passwordContainer);
-
- // °´Å¥ÇøÓò
- var buttonContainer = new Horizontal();
- buttonContainer.setSpacing(10);
- buttonContainer.setAlignment("center");
-
- var submitBtn = new Button();
- submitBtn.setText("Ìá½»");
- submitBtn.setColor(0, 122, 255);
- submitBtn.setTextColor(255, 255, 255);
- submitBtn.setWidth(100);
- submitBtn.setHeight(40);
-
- submitBtn.onClick(() => {
- var username = usernameInput.getText();
- var password = passwordInput.getText();
- printl("Óû§Ãû: " + username);
- printl("ÃÜÂë: " + password);
-
- var resultLabel = new Label();
- resultLabel.setText("Ìá½»³É¹¦£¡Óû§Ãû: " + username);
- resultLabel.setFontSize(12.0);
- resultLabel.setTextColor(52, 199, 89);
- applicationContainer.addView(resultLabel);
- });
-
- var resetBtn = new Button();
- resetBtn.setText("ÖØÖÃ");
- resetBtn.setColor(255, 149, 0);
- resetBtn.setTextColor(255, 255, 255);
- resetBtn.setWidth(100);
- resetBtn.setHeight(40);
-
- resetBtn.onClick(() => {
- usernameInput.setText("");
- passwordInput.setText("");
- printl("ÊäÈë¿òÒÑÖØÖÃ");
- });
-
- buttonContainer.addView(submitBtn);
- buttonContainer.addView(resetBtn);
- applicationContainer.addView(buttonContainer);
- mainContainer.addView(applicationContainer);
-
- // ¿Ø¼þÐÅÏ¢ÇøÓò
- var infoContainer = new Vertical();
- infoContainer.setBackgroundColor(236, 245, 255);
- infoContainer.setSpacing(8);
-
- var infoTitle = new Label();
- infoTitle.setText("ℹ️ Input¿Ø¼þ˵Ã÷");
- infoTitle.setFontSize(16.0);
- infoTitle.setTextColor(0, 122, 255);
- infoContainer.addView(infoTitle);
-
- var info1 = new Label();
- info1.setText("• Input¿Ø¼þÓÃÓÚ½ÓÊÕÓû§ÊäÈë");
- info1.setFontSize(12.0);
- info1.setTextColor(52, 58, 64);
- infoContainer.addView(info1);
-
- var info2 = new Label();
- info2.setText("• Ö§³ÖÎı¾ÉèÖᢻñÈ¡ºÍÑùʽ¶¨ÖÆ");
- info2.setFontSize(12.0);
- info2.setTextColor(52, 58, 64);
- infoContainer.addView(info2);
-
- var info3 = new Label();
- info3.setText("• ¿Éͨ¹ýsetID±£´æºÍ¶ÁÈ¡ÅäÖÃ");
- info3.setFontSize(12.0);
- info3.setTextColor(52, 58, 64);
- infoContainer.addView(info3);
-
- mainContainer.addView(infoContainer);
-
- // µ×²¿°´Å¥
- var bottomContainer = new Horizontal();
- bottomContainer.setSpacing(10);
- bottomContainer.setAlignment("center");
-
- var exitBtn = new Button();
- exitBtn.setText("Í˳öʾÀý");
- exitBtn.setColor(255, 59, 48);
- exitBtn.setTextColor(255, 255, 255);
- exitBtn.setHeight(40);
-
- exitBtn.onClick(() => {
- printl("Í˳ö°´Å¥±»µã»÷");
- vc.dismiss();
- });
-
- bottomContainer.addView(exitBtn);
- mainContainer.addView(bottomContainer);
-
- // Ìí¼Óµ½Ö÷ÊÓͼ
- view.addView(mainContainer);
-
- printl("InputʾÀý½çÃæ¹¹½¨Íê³É");
- });
- printl("Input¿Ø¼þÍêÕûʾÀýÒÑÆô¶¯");
¸´ÖÆ´úÂë
|