坐標(biāo)與位置
- CGPoint CGPointMake 坐標(biāo)點
- CGSize CGRectMake 矩形尺寸
- CGRect CGSizeMake 矩形坐標(biāo)&尺寸
CGPoint point = CGPointMake(0.0f, 0.0f);
CGSize size = CGSizeMake(10.0f, 10.0f);
CGRect rect = CGRectMake(point.x, point.y, size.width, size.height);
NSLog(@"point: %@", NSStringFromCGPoint(point));
NSLog(@"size: %@", NSStringFromCGSize(size));
NSLog(@"rect: %@", NSStringFromCGRect(rect));
間距
iOS 的控件, UIButton可以設(shè)置 Padding/Insets谷朝,即按鈕上文字或圖片與按鈕邊界的間隙洲押,對與 CSS 來說叫做 Padding,在 iOS 中叫做 Insets圆凰,UIButton 設(shè)置 Insets 相應(yīng)的屬性如下:
UIEdgeInsets UIEdgeInsetsMake (
CGFloat top,
CGFloat left,
CGFloat bottom,
CGFloat right
);
它們接受的屬性類型是:UIEdgeInsets杈帐,由函數(shù) UIEdgeInsetsMake ( CGFloat top, CGFloat left, CGFloat bottom, CGFloat right )
構(gòu)造出,分別表示其中的內(nèi)容離各邊的距離专钉。
實際中可以用來做下拉刷新的時候頂部footer的停留空間挑童。
[UIView animateWithDuration:0.4 animations:^(void){
self.tableView.contentInset = UIEdgeInsetsMake(
[self headerRefreshHeight], 0, 0, 0
);
}];
參考點frame與bounds
-(CGRect)frame{
return CGRectMake(self.frame.origin.x,self.frame.origin.y,self.frame.size.width,self.frame.size.height);
}
-(CGRect)bounds{
return CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
}
斯坦福iOS教程視頻中的圖片
frame: 該view在父view坐標(biāo)系統(tǒng)中的位置和大小。(參照點是跃须,父親的坐標(biāo)系統(tǒng))
bounds:該view在本地坐標(biāo)系統(tǒng)中的位置和大小站叼。(參照點是,本地坐標(biāo)系統(tǒng)回怜,就相當(dāng)于ViewB自己的坐標(biāo)系統(tǒng)大年,以0,0點為起點)
center:該view的中心點在父view坐標(biāo)系統(tǒng)中的位置和大小。(參照點是玉雾,父親的坐標(biāo)系統(tǒng))