看一下源码就知道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);
}frame: 该view在父view坐标系统中的位置和大小。(参照点是:父亲的坐标系统)
bounds:该view在本地坐标系统中的位置和大小。(参照点是:本地坐标系统,就相当于View自己的坐标系统,以0,0点为起点)
center:该view的中心点在父view坐标系统中的位置和大小。(参照点是:父亲的坐标系统)
origin是frame或bounds的左上角坐标
contentSize是contentView的大小
contentInset就相当于html中的padding,是view相对于子view的距离有四个属性
例如UIEdgeInsets(top: 10.0, left: 20.0, bottom: 30.0, right: 40.0)
contentOffset是scrollview当前显示区域顶点相对于frame顶点的偏移量
假如有一个ScrollView(scrollViewA),设置scrollViewA的contentInset为UIEdgeInsets(top: 10.0, left: 20.0, bottom: 30.0, right: 40.0),
那么
scrollViewA的bounds为(-20,-10)
scrollViewA的contentOffset为(-20,-10)
在scrollViewA的内容滚动时contentSize是不变的
contentInset也是不变的
变得只是contentOffset和bounds
并且contentOffset和bounds的值是一样的
上拉y变大,下拉y变小
左拉x变大,右拉x变小
可以这样想以scrollViewA的左上角为坐标系原点y轴向上为正,x轴向左为正,那么contentOffset和bounds就是contentView的左上角在该坐标系的坐标