iOS文档-UIView的基本属性
2014-02-14 21:57
253 查看
注:以下内容为本人根据苹果官方文档加上自己的理解写成。
UIView #苹果官方文档对UIView(UIViewGeometry)的描述如下: // animatable. do not use frame if view is transformed //since it will not correctly reflect the actual location of the view. //use bounds + center instead. 大概意思就是:frame是可动画属性,当view发生形变时,而如果它不能正确表示出view的实际位置, 就是用bounds与center的组合代替. ^四大基本属性^ 1.frame : origin && size : x,y && width,height UIView *_myView = [[UIView alloc] init]; 由于OC语法规定,不允许直接修改 某个对象中结构体属性的成员,因此对frame属性操作一般如下 Step 1>.取出view的frame CGRect tempFrame = _myView.frame; 2>.对tempFrame进行具体操作 3>.重新赋值给原来的frame _myView.frame = tempFrame; #对frame属性的描述如下: // use bounds/center and not frame if non-identity transform. //if bounds dimension is odd, center may be have fractional part 大概意思就是: 如果transform属性为非同一性,使用bounds或者center属性。 如果bounds的尺寸是奇数,center可能会有小数部分. 2.bounds: origin 一般都是(0,0) ,size : width && height #对bounds属性的描述如下: // default bounds is zero origin, frame size. animatable 3.center: 是frame属性的中点 #对center属性的描述如下: // center is center of frame. animatable 4.transform:形变属性 #对transform属性的描述如下: // center is center of frame. animatable // default is CGAffineTransformIdentity. animatable CGAffineTransform结构体定义如下 typedef struct CGAffineTransform CGAffineTransform; struct CGAffineTransform { CGFloat a, b, c, d; CGFloat tx, ty; }; *切记,frame属性与center属性的原点(0,0)是父控件的左上角。 *只有bounds属性的原点是自己的左上角。 PS: CGRect 有2个成员,分别是 CGFloat,CGSize 两个结构体 其定义如下: //CGRect的定义 struct CGRect { CGPoint origin; CGSize size; }; typedef struct CGRect CGRect; //CGPoint的定义 struct CGPoint { CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint; //CGSize的定义 struct CGSize { CGFloat width; CGFloat height; }; typedef struct CGSize CGSize;
相关文章推荐
- 基本控件文档-UIView属性---iOS-Apple苹果官方文档翻译
- iOS UIView 基本属性用法
- ios--UIView的基本属性和自定义
- 基本控件文档-UISlider属性---iOS-Apple苹果官方文档翻译
- 基本控件文档-UISwitch属性---iOS-Apple苹果官方文档翻译
- IOS-- UIView 基本属性用法
- iOS uiview基本属性用法
- iOS中的UIView的基本属性1
- 基本控件文档-UITextField属性---iOS-Apple苹果官方文档翻译
- IOS的基本控件的使用-UIView的基本属性
- IOS基本控件常用属性及方法(七)---UIView
- 基本控件文档-UIButton属性---iOS-Apple苹果官方文档翻译
- 基本控件文档-UILabel属性---iOS-Apple苹果官方文档翻译
- 基本控件文档-UIView属性
- iOS中的UIView的基本属性
- 基本控件文档-UISegment属性----iOS-Apple苹果官方文档翻译
- iOS_Core Animation UIView的transform属性
- IOS开发入门基本知识——(UIButton UIView UILabel的创建)
- iOS UIView非常用方法及属性详解
- ISOUI控件--创建画板,UIView,UILable,UITextField,UIButton基本属性