在程序中看到這樣代碼? ? ? self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
在網(wǎng)上查了查,博主講的比較清楚部凑,此處做一個(gè)保留
UIView中有個(gè)屬性是autoresizingMask,該屬性是用來控制控件的自適應(yīng)电谣。
UIViewAutoresizingNone
UIViewAutoresizingFlexibleLeftMargin
UIViewAutoresizingFlexibleWidth
UIViewAutoresizingFlexibleRightMargin
UIViewAutoresizingFlexibleTopMargin
UIViewAutoresizingFlexibleHeight
UIViewAutoresizingFlexibleBottomMargin
UIViewAutoresizingNone:控件相對(duì)于父視圖坐標(biāo)值不變尼酿;
UIViewAutoresizingFlexibleWidth:控件的寬度隨著父視圖的寬度按比例改變;
例如:label寬度為100殉挽,屏幕的寬度為320丰涉。當(dāng)屏幕寬度為480時(shí),label寬度變?yōu)?00*480/320
UIViewAutoresizingFlexibleHeight:與UIViewAutoresizingFlexibleWidth相同
UIViewAutoresizingFlexibleLeftMargin:到屏幕左邊的距離隨著父視圖的寬度按比例改變斯碌;
例如:CGRectMake(50, 100, 200, 40)]; 當(dāng)屏幕的寬度為320一死,x為50;當(dāng)屏幕寬度為480時(shí)傻唾,labelx坐標(biāo)變?yōu)?50*480/320投慈。
控件坐標(biāo)變?yōu)?CGRectMake(75, 100, 200, 40)];
UIViewAutoresizingFlexibleRightMargin
UIViewAutoresizingFlexibleTopMargin
UIViewAutoresizingFlexibleBottomMargin
UIViewAutoresizingFlexibleLeftMargin類似