|
AIWROKÈí¼þIOSÆ»¹ûÏßÌõÀà[Line]·½·¨Ð¡½á
- // µÚÒ»¸ö·½·¨£º📌setWidth - ÉèÖÃÏßÌõ¿í¶È
- /*
- Àà±ð ÏêÇé˵Ã÷
- ·½·¨¹¦ÄÜ ÉèÖÃÏßÌõµÄ¿í¶È
- ·½·¨Ç©Ãû Void setWidth (Single width)
- ·µ»ØÖµ ·µ»ØÖµ: Void
- ²ÎÊý - Single width£ºÓÃÓÚÖ¸¶¨ÏßÌõ¿í¶ÈµÄµ¥¾«¶È¸¡µãÊý²ÎÊý
- */
- // ʾÀý£ºÉèÖÃÏßÌõ¿í¶È
- var line = new Line ();
- line.setWidth (5.0f); // ÉèÖÃÏßÌõ¿í¶ÈΪ 5
- // µÚ¶þ¸ö·½·¨£º📌setHeight - ÉèÖÃÏßÌõ¸ß¶È
- /*
- Àà±ð ÏêÇé˵Ã÷
- ·½·¨¹¦ÄÜ ÉèÖÃÏßÌõµÄ¸ß¶È
- ·½·¨Ç©Ãû Void setHeight (Single height)
- ·µ»ØÖµ ·µ»ØÖµ: Void
- ²ÎÊý - Single height£ºÓÃÓÚÖ¸¶¨ÏßÌõ¸ß¶ÈµÄµ¥¾«¶È¸¡µãÊý²ÎÊý
- */
- // ʾÀý£ºÉèÖÃÏßÌõ¸ß¶È
- var line = new Line ();
- line.setHeight (2.0f); // ÉèÖÃÏßÌõ¸ß¶ÈΪ 2
- // µÚÈý¸ö·½·¨£º📌setColor - ÉèÖÃÏßÌõÑÕÉ«
- /*
- Àà±ð ÏêÇé˵Ã÷
- ·½·¨¹¦ÄÜ ÉèÖÃÏßÌõµÄÑÕÉ«
- ·½·¨Ç©Ãû Void setColor (Single red, Single green, Single blue)
- ·µ»ØÖµ ·µ»ØÖµ: Void
- ²ÎÊý - Single red£ººìɫͨµÀµÄµ¥¾«¶È¸¡µãÊý²ÎÊý
- Single green£ºÂÌɫͨµÀµÄµ¥¾«¶È¸¡µãÊý²ÎÊý
- Single blue£ºÀ¶É«Í¨µÀµÄµ¥¾«¶È¸¡µãÊý²ÎÊý
- */
- // ʾÀý£ºÉèÖÃÏßÌõÑÕÉ«
- var line = new Line ();
- line.setColor (255, 0, 0); // ÉèÖÃÏßÌõÑÕɫΪºìÉ«
¸´ÖÆ´úÂë
1. ÏßÌõ¿í¶ÈÉèÖ÷½·¨ÏîÄ¿ | ÄÚÈÝ | ¹¦ÄÜÃèÊö | ÉèÖÃÏßÌõµÄ¿í¶È | ·½·¨ÉùÃ÷ | Void setWidth(Single width) | ·µ»ØÖµ | ·µ»ØÖµ: Void | ²ÎÊý | Single width £ºÓÃÓÚÖ¸¶¨ÏßÌõ¿í¶ÈµÄµ¥¾«¶È¸¡µãÊý²ÎÊý | °¸Àý | csharp<br>var line = new Line();<br>line.setWidth(5.0f); // ÉèÖÃÏßÌõ¿í¶ÈΪ5<br> | 2. ÏßÌõ¸ß¶ÈÉèÖ÷½·¨ÏîÄ¿ | ÄÚÈÝ | ¹¦ÄÜÃèÊö | ÉèÖÃÏßÌõµÄ¸ß¶È | ·½·¨ÉùÃ÷ | Void setHeight(Single height) | ·µ»ØÖµ | ·µ»ØÖµ: Void | ²ÎÊý | Single height £ºÓÃÓÚÖ¸¶¨ÏßÌõ¸ß¶ÈµÄµ¥¾«¶È¸¡µãÊý²ÎÊý | °¸Àý | csharp<br>var line = new Line();<br>line.setHeight(2.0f); // ÉèÖÃÏßÌõ¸ß¶ÈΪ2<br> | 3. ÏßÌõÑÕÉ«ÉèÖ÷½·¨ÏîÄ¿ | ÄÚÈÝ | ¹¦ÄÜÃèÊö | ÉèÖÃÏßÌõµÄÑÕÉ« | ·½·¨ÉùÃ÷ | Void setColor(Single red, Single green, Single blue) | ·µ»ØÖµ | ·µ»ØÖµ: Void | ²ÎÊý | - Single red £ººìɫͨµÀµÄµ¥¾«¶È¸¡µãÊý²ÎÊý
- Single green £ºÂÌɫͨµÀµÄµ¥¾«¶È¸¡µãÊý²ÎÊý
- Single blue £ºÀ¶É«Í¨µÀµÄµ¥¾«¶È¸¡µãÊý²ÎÊý | °¸Àý | csharp<br>var line = new Line();<br>line.setColor(255, 0, 0); // ÉèÖÃÏßÌõÑÕɫΪºìÉ«<br> |
ʵÓÃÑÝʾÀý×Ó£º
- // 🔨🍎UI-LineÏßÌõÀà[Line]·½·¨ÍêÕûʾÀý
- // UI-LineÏßÌõÀà·½·¨Ð¡½á£¬½»Á÷QQȺ711841924
- printl("=== Line¿Ø¼þ·½·¨ÍêÕûʾÀý ===");
- // ´´½¨ÊÓͼÈÝÆ÷
- var vc = new IOSView();
- vc.show(() => {
- printl("LineʾÀý½çÃæÒѼÓÔØ");
-
- // »ñÈ¡µ±Ç°ÊÓͼ
- var view = vc.getView();
-
- // ´´½¨Ö÷ÈÝÆ÷
- var mainContainer = new Vertical();
- mainContainer.setSpacing(20);
- 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("🔨 LineÏßÌõ¿Ø¼þÑÝʾ");
- titleLabel.setFontSize(20.0);
- titleLabel.setTextColor(255, 255, 255);
- titleLabel.setTextAlignment("center");
-
- var subtitleLabel = new Label();
- subtitleLabel.setText("Line¿Ø¼þ·½·¨Ê¹ÓÃʾÀý");
- subtitleLabel.setFontSize(14.0);
- subtitleLabel.setTextColor(255, 255, 255);
- subtitleLabel.setTextAlignment("center");
-
- titleContainer.addView(titleLabel);
- titleContainer.addView(subtitleLabel);
- mainContainer.addView(titleContainer);
-
- // Line·½·¨ÑÝÊ¾ÇøÓò
- var demoContainer = new Vertical();
- demoContainer.setBackgroundColor(255, 255, 255);
- demoContainer.setSpacing(15);
-
- var demoTitle = new Label();
- demoTitle.setText("Line¿Ø¼þ¹¦ÄÜÑÝʾ");
- demoTitle.setFontSize(18.0);
- demoTitle.setTextColor(0, 0, 0);
- demoTitle.setTextAlignment("center");
- demoContainer.addView(demoTitle);
-
- // µÚÒ»¸ö·½·¨£ºsetWidthÉèÖÃÏßÌõ¿í¶ÈÑÝʾ
- var widthDemo = new Vertical();
- widthDemo.setSpacing(10);
-
- var widthLabel = new Label();
- widthLabel.setText("📌 setWidthÉèÖÃÏßÌõ¿í¶È");
- widthLabel.setFontSize(16.0);
- widthLabel.setTextColor(0, 122, 255);
- widthDemo.addView(widthLabel);
-
- var widthDesc = new Label();
- widthDesc.setText("´´½¨²»Í¬¿í¶ÈµÄÏßÌõ:");
- widthDesc.setFontSize(14.0);
- widthDesc.setTextColor(100, 100, 100);
- widthDemo.addView(widthDesc);
-
- // ´´½¨²»Í¬¿í¶ÈµÄÏßÌõʾÀý
- var line1 = new Line();
- line1.setWidth(5.0); // ÉèÖÃÏßÌõ¿í¶ÈΪ 5
- line1.setHeight(1.0);
- line1.setColor(255, 0, 0); // ºìÉ«ÏßÌõ
- widthDemo.addView(line1);
-
- var lineDesc1 = new Label();
- lineDesc1.setText("¿í¶È: 5.0");
- lineDesc1.setFontSize(12.0);
- lineDesc1.setTextColor(150, 150, 150);
- widthDemo.addView(lineDesc1);
-
- var line2 = new Line();
- line2.setWidth(10.0); // ÉèÖÃÏßÌõ¿í¶ÈΪ 10
- line2.setHeight(1.0);
- line2.setColor(0, 255, 0); // ÂÌÉ«ÏßÌõ
- widthDemo.addView(line2);
-
- var lineDesc2 = new Label();
- lineDesc2.setText("¿í¶È: 10.0");
- lineDesc2.setFontSize(12.0);
- lineDesc2.setTextColor(150, 150, 150);
- widthDemo.addView(lineDesc2);
-
- var line3 = new Line();
- line3.setWidth(15.0); // ÉèÖÃÏßÌõ¿í¶ÈΪ 15
- line3.setHeight(1.0);
- line3.setColor(0, 0, 255); // À¶É«ÏßÌõ
- widthDemo.addView(line3);
-
- var lineDesc3 = new Label();
- lineDesc3.setText("¿í¶È: 15.0");
- lineDesc3.setFontSize(12.0);
- lineDesc3.setTextColor(150, 150, 150);
- widthDemo.addView(lineDesc3);
-
- demoContainer.addView(widthDemo);
-
- // Ìí¼Ó·Ö¸î¿Õ¼ä
- var separator1 = new Space();
- separator1.setHeight(10.0);
- demoContainer.addView(separator1);
-
- // µÚ¶þ¸ö·½·¨£ºsetHeightÉèÖÃÏßÌõ¸ß¶ÈÑÝʾ
- var heightDemo = new Vertical();
- heightDemo.setSpacing(10);
-
- var heightLabel = new Label();
- heightLabel.setText("📌 setHeightÉèÖÃÏßÌõ¸ß¶È");
- heightLabel.setFontSize(16.0);
- heightLabel.setTextColor(0, 122, 255);
- heightDemo.addView(heightLabel);
-
- var heightDesc = new Label();
- heightDesc.setText("´´½¨²»Í¬¸ß¶ÈµÄÏßÌõ:");
- heightDesc.setFontSize(14.0);
- heightDesc.setTextColor(100, 100, 100);
- heightDemo.addView(heightDesc);
-
- // ´´½¨²»Í¬¸ß¶ÈµÄÏßÌõʾÀý
- var hLine1 = new Line();
- hLine1.setWidth(200.0);
- hLine1.setHeight(2.0); // ÉèÖÃÏßÌõ¸ß¶ÈΪ 2
- hLine1.setColor(255, 165, 0); // ³ÈÉ«ÏßÌõ
- heightDemo.addView(hLine1);
-
- var hLineDesc1 = new Label();
- hLineDesc1.setText("¸ß¶È: 2.0");
- hLineDesc1.setFontSize(12.0);
- hLineDesc1.setTextColor(150, 150, 150);
- heightDemo.addView(hLineDesc1);
-
- var hLine2 = new Line();
- hLine2.setWidth(200.0);
- hLine2.setHeight(5.0); // ÉèÖÃÏßÌõ¸ß¶ÈΪ 5
- hLine2.setColor(128, 0, 128); // ×ÏÉ«ÏßÌõ
- heightDemo.addView(hLine2);
-
- var hLineDesc2 = new Label();
- hLineDesc2.setText("¸ß¶È: 5.0");
- hLineDesc2.setFontSize(12.0);
- hLineDesc2.setTextColor(150, 150, 150);
- heightDemo.addView(hLineDesc2);
-
- var hLine3 = new Line();
- hLine3.setWidth(200.0);
- hLine3.setHeight(8.0); // ÉèÖÃÏßÌõ¸ß¶ÈΪ 8
- hLine3.setColor(0, 128, 128); // ÇàÉ«ÏßÌõ
- heightDemo.addView(hLine3);
-
- var hLineDesc3 = new Label();
- hLineDesc3.setText("¸ß¶È: 8.0");
- hLineDesc3.setFontSize(12.0);
- hLineDesc3.setTextColor(150, 150, 150);
- heightDemo.addView(hLineDesc3);
-
- demoContainer.addView(heightDemo);
-
- // Ìí¼Ó·Ö¸î¿Õ¼ä
- var separator2 = new Space();
- separator2.setHeight(10.0);
- demoContainer.addView(separator2);
-
- // µÚÈý¸ö·½·¨£ºsetColorÉèÖÃÏßÌõÑÕÉ«ÑÝʾ
- var colorDemo = new Vertical();
- colorDemo.setSpacing(10);
-
- var colorLabel = new Label();
- colorLabel.setText("📌 setColorÉèÖÃÏßÌõÑÕÉ«");
- colorLabel.setFontSize(16.0);
- colorLabel.setTextColor(0, 122, 255);
- colorDemo.addView(colorLabel);
-
- var colorDesc = new Label();
- colorDesc.setText("´´½¨²»Í¬ÑÕÉ«µÄÏßÌõ:");
- colorDesc.setFontSize(14.0);
- colorDesc.setTextColor(100, 100, 100);
- colorDemo.addView(colorDesc);
-
- // ´´½¨²»Í¬ÑÕÉ«µÄÏßÌõʾÀý
- var colorLine1 = new Line();
- colorLine1.setWidth(250.0);
- colorLine1.setHeight(3.0);
- colorLine1.setColor(255, 0, 0); // ÉèÖÃÏßÌõÑÕɫΪºìÉ« (255, 0, 0)
- colorDemo.addView(colorLine1);
-
- var colorLineDesc1 = new Label();
- colorLineDesc1.setText("ÑÕÉ«: ºìÉ« (255, 0, 0)");
- colorLineDesc1.setFontSize(12.0);
- colorLineDesc1.setTextColor(150, 150, 150);
- colorDemo.addView(colorLineDesc1);
-
- var colorLine2 = new Line();
- colorLine2.setWidth(250.0);
- colorLine2.setHeight(3.0);
- colorLine2.setColor(0, 255, 0); // ÉèÖÃÏßÌõÑÕɫΪÂÌÉ« (0, 255, 0)
- colorDemo.addView(colorLine2);
-
- var colorLineDesc2 = new Label();
- colorLineDesc2.setText("ÑÕÉ«: ÂÌÉ« (0, 255, 0)");
- colorLineDesc2.setFontSize(12.0);
- colorLineDesc2.setTextColor(150, 150, 150);
- colorDemo.addView(colorLineDesc2);
-
- var colorLine3 = new Line();
- colorLine3.setWidth(250.0);
- colorLine3.setHeight(3.0);
- colorLine3.setColor(0, 0, 255); // ÉèÖÃÏßÌõÑÕɫΪÀ¶É« (0, 0, 255)
- colorDemo.addView(colorLine3);
-
- var colorLineDesc3 = new Label();
- colorLineDesc3.setText("ÑÕÉ«: À¶É« (0, 0, 255)");
- colorLineDesc3.setFontSize(12.0);
- colorLineDesc3.setTextColor(150, 150, 150);
- colorDemo.addView(colorLineDesc3);
-
- var colorLine4 = new Line();
- colorLine4.setWidth(250.0);
- colorLine4.setHeight(3.0);
- colorLine4.setColor(255, 255, 0); // ÉèÖÃÏßÌõÑÕɫΪ»ÆÉ« (255, 255, 0)
- colorDemo.addView(colorLine4);
-
- var colorLineDesc4 = new Label();
- colorLineDesc4.setText("ÑÕÉ«: »ÆÉ« (255, 255, 0)");
- colorLineDesc4.setFontSize(12.0);
- colorLineDesc4.setTextColor(150, 150, 150);
- colorDemo.addView(colorLineDesc4);
-
- demoContainer.addView(colorDemo);
-
- mainContainer.addView(demoContainer);
-
- // ʵ¼ÊÓ¦ÓÃʾÀý
- var applicationContainer = new Vertical();
- applicationContainer.setBackgroundColor(255, 255, 255);
- applicationContainer.setSpacing(15);
-
- var appTitle = new Label();
- appTitle.setText("Lineʵ¼ÊÓ¦ÓÃʾÀý");
- appTitle.setFontSize(18.0);
- appTitle.setTextColor(0, 0, 0);
- appTitle.setTextAlignment("center");
- applicationContainer.addView(appTitle);
-
- var appDesc = new Label();
- appDesc.setText("ʹÓÃLine¿Ø¼þ´´½¨·Ö¸ôÏß:");
- appDesc.setFontSize(14.0);
- appDesc.setTextColor(100, 100, 100);
- applicationContainer.addView(appDesc);
-
- // ±íµ¥²¼¾ÖʾÀý
- var formContainer = new Vertical();
- formContainer.setSpacing(10);
-
- // Óû§ÃûÐÐ
- var usernameRow = new Horizontal();
- usernameRow.setSpacing(10);
-
- var usernameLabel = new Label();
- usernameLabel.setText("Óû§Ãû:");
- usernameLabel.setWidth(60);
- usernameLabel.setTextColor(0, 0, 0);
-
- var usernameInput = new Input();
- usernameInput.setPlaceholder("ÇëÊäÈëÓû§Ãû");
- usernameInput.setWidth(200);
- usernameInput.setHeight(40);
- usernameInput.setBackgroundColor(240, 240, 240);
-
- usernameRow.addView(usernameLabel);
- usernameRow.addView(usernameInput);
- formContainer.addView(usernameRow);
-
- // Ìí¼Ó·Ö¸ôÏß
- var separatorLine1 = new Line();
- separatorLine1.setWidth(300.0);
- separatorLine1.setHeight(1.0);
- separatorLine1.setColor(200, 200, 200);
- formContainer.addView(separatorLine1);
-
- // ÃÜÂëÐÐ
- var passwordRow = new Horizontal();
- passwordRow.setSpacing(10);
-
- var passwordLabel = new Label();
- passwordLabel.setText("ÃÜÂë:");
- passwordLabel.setWidth(60);
- passwordLabel.setTextColor(0, 0, 0);
-
- var passwordInput = new Input();
- passwordInput.setPlaceholder("ÇëÊäÈëÃÜÂë");
- passwordInput.setWidth(200);
- passwordInput.setHeight(40);
- passwordInput.setBackgroundColor(240, 240, 240);
-
- passwordRow.addView(passwordLabel);
- passwordRow.addView(passwordInput);
- formContainer.addView(passwordRow);
-
- // Ìí¼Ó·Ö¸ôÏß
- var separatorLine2 = new Line();
- separatorLine2.setWidth(300.0);
- separatorLine2.setHeight(1.0);
- separatorLine2.setColor(200, 200, 200);
- formContainer.addView(separatorLine2);
-
- // ÓÊÏäÐÐ
- var emailRow = new Horizontal();
- emailRow.setSpacing(10);
-
- var emailLabel = new Label();
- emailLabel.setText("ÓÊÏä:");
- emailLabel.setWidth(60);
- emailLabel.setTextColor(0, 0, 0);
-
- var emailInput = new Input();
- emailInput.setPlaceholder("ÇëÊäÈëÓÊÏä");
- emailInput.setWidth(200);
- emailInput.setHeight(40);
- emailInput.setBackgroundColor(240, 240, 240);
-
- emailRow.addView(emailLabel);
- emailRow.addView(emailInput);
- formContainer.addView(emailRow);
-
- applicationContainer.addView(formContainer);
-
- // °´Å¥ÇøÓò
- 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();
- var email = emailInput.getText();
- printl("Óû§Ãû: " + username);
- printl("ÃÜÂë: " + password);
- printl("ÓÊÏä: " + email);
-
- var resultLabel = new Label();
- resultLabel.setText("Ìá½»³É¹¦£¡");
- resultLabel.setFontSize(14.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("");
- emailInput.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("ℹ️ Line¿Ø¼þ˵Ã÷");
- infoTitle.setFontSize(16.0);
- infoTitle.setTextColor(0, 122, 255);
- infoContainer.addView(infoTitle);
-
- var info1 = new Label();
- info1.setText("• Line¿Ø¼þÓÃÓÚ´´½¨ÏßÌõÔªËØ");
- info1.setFontSize(12.0);
- info1.setTextColor(52, 58, 64);
- infoContainer.addView(info1);
-
- var info2 = new Label();
- info2.setText("• ¿Éͨ¹ýsetWidth/setHeightÉèÖÃÏßÌõ³ß´ç");
- info2.setFontSize(12.0);
- info2.setTextColor(52, 58, 64);
- infoContainer.addView(info2);
-
- var info3 = new Label();
- info3.setText("• ¿Éͨ¹ýsetColorÉèÖÃÏßÌõÑÕÉ«");
- info3.setFontSize(12.0);
- info3.setTextColor(52, 58, 64);
- infoContainer.addView(info3);
-
- var info4 = new Label();
- info4.setText("• ³£ÓÃÓÚ½çÃæ·Ö¸ôºÍ×°ÊÎ");
- info4.setFontSize(12.0);
- info4.setTextColor(52, 58, 64);
- infoContainer.addView(info4);
-
- 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("LineʾÀý½çÃæ¹¹½¨Íê³É");
- });
- printl("Line¿Ø¼þÍêÕûʾÀýÒÑÆô¶¯");
¸´ÖÆ´úÂë
|
|