1 -(void)fun1,這個詞典應當包含需要自動布局的父檢視和所有的子檢視,
24*/
25 nsarray *arr1 = [nslayoutconstraint constraintswithvisualformat:@"
v:|-20-[view]-|
" options:0
metrics:nil views:nsdictionaryofvariablebindings(view)];
2627
[self.view addconstraints:arr];
28[self.view addconstraints:arr1];
2930}31
32 -(void
)fun2
4748 -(void
)fun3 views:nsdictionaryofvariablebindings(view)];
5960 nsarray *arr1 = [nslayoutconstraint constraintswithvisualformat:@"
v:|-20-[view(==100)]
" options:0
metrics:nil views:nsdictionaryofvariablebindings(view)];
61[self.view addconstraints:arr1];
62[self.view addconstraints:arr];
6364}65
66 -(void
)fun4 views:nsdictionaryofvariablebindings(view)];
7778 nsarray *arr1 = [nslayoutconstraint constraintswithvisualformat:@"
v:|-20-[view(==100)]
" options:0
metrics:nil views:nsdictionaryofvariablebindings(view)];
79[self.view addconstraints:arr1];
80[self.view addconstraints:arr];
8182
83 uiview *view1 =[[uiview alloc] init];
84 view1.backgroundcolor =[uicolor purplecolor];
85[self.view addsubview:view1];
8687 view1.translatesautoresizingmaskintoconstraints =no;
8889
//[view1(view)] 代表view1和view某個方向尺寸相同
90 nsarray *arr2 = [nslayoutconstraint constraintswithvisualformat:@"
h:|-[view1(view)]-|
" options:0
metrics:nil views:nsdictionaryofvariablebindings(view1,view)];
9192
//v:[view]-[view1]-20-|:子檢視view1垂直方向距離平級子檢視view 8畫素(預設)
93 nsarray *arr3 = [nslayoutconstraint constraintswithvisualformat:@"
v:[view]-[view1]-20-|
" options:0
metrics:nil views:nsdictionaryofvariablebindings(view,view1)];
94[self.view addconstraints:arr2];
95[self.view addconstraints:arr3];
969798}
99100
//用vfl實現label自適應
101 -(void
)fun5
螢幕自適應
1 media screen and max width 240px 寬度小於240px執行 media screen and min width 240px 寬度大於240px執行 2 flexible.js 在所有資源載入之前先放入 3 使用數值單位時可以嘗試使用rem作為單位替代px。rem一...
vue專案螢幕自適應 Vue專案螢幕自適應
一 安裝lib flexible npm i lib flexible d 二 在main.js中引入 import lib flexible flexible 三 在index.html檔案中設定meta標籤 四 然後在專案中寫css時會自動將rem轉化為px,需要安裝px2rem這個工具 npm...
vue專案螢幕自適應 Vue專案螢幕自適應
一 安裝lib flexible npm i lib flexible d 二 在main.js中引入 import lib flexible flexible 三 在index.html檔案中設定meta標籤 四 然後在專案中寫css時會自動將rem轉化為px,需要安裝px2rem這個工具 npm...