- //Ul-¿Õ°×վλ[Space]·½·¨Ð¡½á£¬½»Á÷QQȺ711841924
- //µÚÒ»¸ö·½·¨£º📌setWidthÉèÖÿí¶È
- var space = new Space();
- space.setWidth(100.0f); // ÉèÖÿռä¿í¶ÈΪ100
- //µÚ¶þ¸ö·½·¨£º📌setHeightÉèÖø߶È
- var space = new Space();
- space.setHeight(50.0f); // ÉèÖÿռä¸ß¶ÈΪ50
- //µÚÈý¸ö·½·¨£º📌setBackgroundColor ÉèÖñ³¾°ÑÕÉ«
- var space = new Space();
- 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); // ÉèÖÿռ䱳¾°ÑÕɫΪ°×É« |
ÍêÕûʾÀý£º
- // 🔨🍎UI-¿Õ°×վλ[Space]·½·¨ÍêÕûʾÀý
- // UI-¿Õ°×վλ[Space]·½·¨Ð¡½á£¬½»Á÷QQȺ711841924
- printl("=== Space¿Ø¼þ·½·¨ÍêÕûʾÀý ===");
- var vc = new IOSView();
- vc.show(() => {
- printl("SpaceʾÀý½çÃæÒѼÓÔØ");
-
- // »ñÈ¡µ±Ç°ÊÓͼ
- 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(0); // µ÷Õû¼ä¾à
- titleContainer.setBackgroundColor(0, 122, 255);
- var titleLabel = new Label();
- titleLabel.setText("🔨 Space¿Ø¼þÑÝʾ");
- 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);
-
- // Space·½·¨ÑÝÊ¾ÇøÓò
- var demoContainer = new Vertical();
- demoContainer.setBackgroundColor(255, 255, 255);
- demoContainer.setSpacing(10);
-
- var demoTitle = new Label();
- demoTitle.setText("Space¿Ø¼þ¹¦ÄÜÑÝʾ");
- demoTitle.setFontSize(16.0);
- demoTitle.setTextColor(0, 0, 0);
- demoTitle.setTextAlignment("center");
- demoContainer.addView(demoTitle);
-
- // µÚÒ»¸ö·½·¨£ºsetWidthÉèÖÿí¶ÈÑÝʾ
- var widthDemo = new Vertical();
- widthDemo.setSpacing(5);
-
- var widthLabel = new Label();
- widthLabel.setText("📌 setWidthÉèÖÿí¶È");
- widthLabel.setFontSize(14.0);
- widthLabel.setTextColor(0, 122, 255);
- widthDemo.addView(widthLabel);
-
- var widthDesc = new Label();
- widthDesc.setText("´´½¨²»Í¬¿í¶ÈµÄ¿Õ°×ռλ:");
- widthDesc.setFontSize(12.0);
- widthDesc.setTextColor(100, 100, 100);
- widthDemo.addView(widthDesc);
-
- // ˮƽÈÝÆ÷չʾ²»Í¬¿í¶ÈµÄSpace
- var widthContainer = new Horizontal();
- widthContainer.setSpacing(5);
- widthContainer.setBackgroundColor(240, 240, 240);
-
- var label1 = new Label();
- label1.setText("W20");
- label1.setFontSize(10.0);
- label1.setBackgroundColor(0, 122, 255);
- label1.setTextColor(255, 255, 255);
-
- // µÚÒ»¸ö·½·¨£ºsetWidthÉèÖÿí¶È
- var space1 = new Space();
- space1.setWidth(20.0); // ÉèÖÿռä¿í¶ÈΪ20
- space1.setBackgroundColor(200, 200, 200); // ÉèÖñ³¾°É«ÒÔ±ã¹Û²ì
-
- var label2 = new Label();
- label2.setText("W50");
- label2.setFontSize(10.0);
- label2.setBackgroundColor(52, 199, 89);
- label2.setTextColor(255, 255, 255);
-
- // µÚÒ»¸ö·½·¨£ºsetWidthÉèÖÿí¶È
- var space2 = new Space();
- space2.setWidth(50.0); // ÉèÖÿռä¿í¶ÈΪ50
- space2.setBackgroundColor(200, 200, 200); // ÉèÖñ³¾°É«ÒÔ±ã¹Û²ì
-
- var label3 = new Label();
- label3.setText("W30");
- label3.setFontSize(10.0);
- label3.setBackgroundColor(255, 149, 0);
- label3.setTextColor(255, 255, 255);
-
- widthContainer.addView(label1);
- widthContainer.addView(space1);
- widthContainer.addView(label2);
- widthContainer.addView(space2);
- widthContainer.addView(label3);
- widthDemo.addView(widthContainer);
- demoContainer.addView(widthDemo);
-
- // Ìí¼Ó·Ö¸î¿Õ¼ä
- var separator1 = new Space();
- separator1.setHeight(10.0);
- demoContainer.addView(separator1);
-
- // µÚ¶þ¸ö·½·¨£ºsetHeightÉèÖø߶ÈÑÝʾ
- var heightDemo = new Vertical();
- heightDemo.setSpacing(5);
-
- var heightLabel = new Label();
- heightLabel.setText("📌 setHeightÉèÖø߶È");
- heightLabel.setFontSize(14.0);
- heightLabel.setTextColor(0, 122, 255);
- heightDemo.addView(heightLabel);
-
- var heightDesc = new Label();
- heightDesc.setText("´´½¨²»Í¬¸ß¶ÈµÄ¿Õ°×ռλ:");
- heightDesc.setFontSize(12.0);
- heightDesc.setTextColor(100, 100, 100);
- heightDemo.addView(heightDesc);
-
- // ´¹Ö±ÈÝÆ÷չʾ²»Í¬¸ß¶ÈµÄSpace
- var heightContainer = new Vertical();
- heightContainer.setBackgroundColor(240, 240, 240);
-
- var hLabel1 = new Label();
- hLabel1.setText("H10");
- hLabel1.setFontSize(10.0);
- hLabel1.setBackgroundColor(0, 122, 255);
- hLabel1.setTextColor(255, 255, 255);
- hLabel1.setTextAlignment("center");
-
- // µÚ¶þ¸ö·½·¨£ºsetHeightÉèÖø߶È
- var space3 = new Space();
- space3.setHeight(10.0); // ÉèÖÿռä¸ß¶ÈΪ10
- space3.setBackgroundColor(200, 200, 200); // ÉèÖñ³¾°É«ÒÔ±ã¹Û²ì
-
- var hLabel2 = new Label();
- hLabel2.setText("H25");
- hLabel2.setFontSize(10.0);
- hLabel2.setBackgroundColor(52, 199, 89);
- hLabel2.setTextColor(255, 255, 255);
- hLabel2.setTextAlignment("center");
-
- // µÚ¶þ¸ö·½·¨£ºsetHeightÉèÖø߶È
- var space4 = new Space();
- space4.setHeight(25.0); // ÉèÖÿռä¸ß¶ÈΪ25
- space4.setBackgroundColor(200, 200, 200); // ÉèÖñ³¾°É«ÒÔ±ã¹Û²ì
-
- var hLabel3 = new Label();
- hLabel3.setText("H15");
- hLabel3.setFontSize(10.0);
- hLabel3.setBackgroundColor(255, 149, 0);
- hLabel3.setTextColor(255, 255, 255);
- hLabel3.setTextAlignment("center");
-
- heightContainer.addView(hLabel1);
- heightContainer.addView(space3);
- heightContainer.addView(hLabel2);
- heightContainer.addView(space4);
- heightContainer.addView(hLabel3);
- heightDemo.addView(heightContainer);
- demoContainer.addView(heightDemo);
-
- // Ìí¼Ó·Ö¸î¿Õ¼ä
- var separator2 = new Space();
- separator2.setHeight(10.0);
- demoContainer.addView(separator2);
-
- // µÚÈý¸ö·½·¨£ºsetBackgroundColor ÉèÖñ³¾°ÑÕÉ«ÑÝʾ
- var colorDemo = new Vertical();
- colorDemo.setSpacing(5);
-
- var colorLabel = new Label();
- colorLabel.setText("📌 setBackgroundColorÉèÖñ³¾°ÑÕÉ«");
- colorLabel.setFontSize(14.0);
- colorLabel.setTextColor(0, 122, 255);
- colorDemo.addView(colorLabel);
-
- var colorDesc = new Label();
- colorDesc.setText("´´½¨²»Í¬±³¾°ÑÕÉ«µÄ¿Õ°×ռλ:");
- colorDesc.setFontSize(12.0);
- colorDesc.setTextColor(100, 100, 100);
- colorDemo.addView(colorDesc);
-
- // ˮƽÈÝÆ÷չʾ²»Í¬±³¾°É«µÄSpace
- var colorContainer = new Horizontal();
- colorContainer.setSpacing(5);
-
- // µÚÈý¸ö·½·¨£ºsetBackgroundColor ÉèÖñ³¾°ÑÕÉ«
- var space5 = new Space();
- space5.setWidth(40.0);
- space5.setHeight(40.0);
- space5.setBackgroundColor(255, 0, 0); // ºìÉ«
-
- // µÚÈý¸ö·½·¨£ºsetBackgroundColor ÉèÖñ³¾°ÑÕÉ«
- var space6 = new Space();
- space6.setWidth(40.0);
- space6.setHeight(40.0);
- space6.setBackgroundColor(0, 255, 0); // ÂÌÉ«
-
- // µÚÈý¸ö·½·¨£ºsetBackgroundColor ÉèÖñ³¾°ÑÕÉ«
- var space7 = new Space();
- space7.setWidth(40.0);
- space7.setHeight(40.0);
- space7.setBackgroundColor(0, 0, 255); // À¶É«
-
- // µÚÈý¸ö·½·¨£ºsetBackgroundColor ÉèÖñ³¾°ÑÕÉ«
- var space8 = new Space();
- space8.setWidth(40.0);
- space8.setHeight(40.0);
- space8.setBackgroundColor(255, 255, 0); // »ÆÉ«
-
- colorContainer.addView(space5);
- colorContainer.addView(space6);
- colorContainer.addView(space7);
- colorContainer.addView(space8);
- colorDemo.addView(colorContainer);
- demoContainer.addView(colorDemo);
-
- mainContainer.addView(demoContainer);
-
- // Spaceʵ¼ÊÓ¦ÓÃʾÀý
- var applicationContainer = new Vertical();
- applicationContainer.setBackgroundColor(255, 255, 255);
- applicationContainer.setSpacing(10);
-
- var appTitle = new Label();
- appTitle.setText("Spaceʵ¼ÊÓ¦ÓÃʾÀý");
- appTitle.setFontSize(16.0);
- appTitle.setTextColor(0, 0, 0);
- appTitle.setTextAlignment("center");
- applicationContainer.addView(appTitle);
-
- var appDesc = new Label();
- appDesc.setText("ʹÓÃSpace¿Ø¼þÓÅ»¯½çÃæ²¼¾Ö:");
- appDesc.setFontSize(12.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 Label();
- usernameInput.setText("ZhangSan");
- usernameInput.setBackgroundColor(240, 240, 240);
-
- usernameRow.addView(usernameLabel);
- usernameRow.addView(usernameInput);
- formContainer.addView(usernameRow);
-
- // Ìí¼Ó´¹Ö±¼ä¾à
- var formSpace = new Space();
- formSpace.setHeight(15.0);
- formContainer.addView(formSpace);
-
- // ÃÜÂëÐÐ
- var passwordRow = new Horizontal();
- passwordRow.setSpacing(10);
-
- var passwordLabel = new Label();
- passwordLabel.setText("ÃÜÂë:");
- passwordLabel.setWidth(60);
- passwordLabel.setTextColor(0, 0, 0);
-
- var passwordInput = new Label();
- passwordInput.setText("********");
- passwordInput.setBackgroundColor(240, 240, 240);
-
- passwordRow.addView(passwordLabel);
- passwordRow.addView(passwordInput);
- formContainer.addView(passwordRow);
-
- applicationContainer.addView(formContainer);
-
- // °´Å¥ÇøÓò
- var buttonContainer = new Horizontal();
- buttonContainer.setSpacing(10);
- buttonContainer.setAlignment("center");
-
- // ʹÓÃSpace´´½¨×óÓÒ¼ä¾à
- var leftSpace = new Space();
- leftSpace.setWidth(20.0);
-
- var loginBtn = new Button();
- loginBtn.setText("怬");
- loginBtn.setColor(0, 122, 255);
- loginBtn.setTextColor(255, 255, 255);
- loginBtn.setWidth(100);
- loginBtn.setHeight(40);
-
- var registerBtn = new Button();
- registerBtn.setText("×¢²á");
- registerBtn.setColor(52, 199, 89);
- registerBtn.setTextColor(255, 255, 255);
- registerBtn.setWidth(100);
- registerBtn.setHeight(40);
-
- var rightSpace = new Space();
- rightSpace.setWidth(20.0);
-
- buttonContainer.addView(leftSpace);
- buttonContainer.addView(loginBtn);
- buttonContainer.addView(registerBtn);
- buttonContainer.addView(rightSpace);
-
- applicationContainer.addView(buttonContainer);
- mainContainer.addView(applicationContainer);
-
- // ¿Ø¼þÐÅÏ¢ÇøÓò
- var infoContainer = new Vertical();
- infoContainer.setBackgroundColor(236, 245, 255);
- infoContainer.setSpacing(8);
-
- var infoTitle = new Label();
- infoTitle.setText("ℹ️ Space¿Ø¼þ˵Ã÷");
- infoTitle.setFontSize(16.0);
- infoTitle.setTextColor(0, 122, 255);
- infoContainer.addView(infoTitle);
-
- var info1 = new Label();
- info1.setText("• Space¿Ø¼þÓÃÓÚ´´½¨¿Õ°×Õ¼Î»ÇøÓò");
- 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("• ¿Éͨ¹ýsetBackgroundColorÉèÖñ³¾°É«");
- 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("SpaceʾÀý½çÃæ¹¹½¨Íê³É");
- });
- printl("Space¿Ø¼þÍêÕûʾÀýÒÑÆô¶¯");
¸´ÖÆ´úÂë
AIWROKÈí¼þÆ»¹ûIOSϵͳUl-¿Õ°×վλ[Space]·½·¨Ð¡½á
|
|