一 UIVIew 常见属性 1.frame 位置和尺寸(以父控件的左上角为原点(0,0)) 2.center 中点 (以父控件的左上角为原点(0,0)) 3.bounds 位置和尺寸(以自己的左上角为原点 (0,0)) 4.transform 形变属性(缩放,旋转) 5.backgroundColor 背景颜色 6.tag 标识(父控件可以根据这个标识找到对应的子控件,同一个父控件中的子控件不要一样) 7. hidden 设置是否要隐藏 8.alpha 透明度(0~1); 9.opaque 不透明度(0~1); 10.userInteractionEnabled 能否跟用户进行交互(YES 能交互) 11.superView 父控件 12.subviews 子控件 13.contentMode 内容显示的模式 拉伸自适应 [view viewWithTag:10]; [ btn1 9 btn2 10 imageView 2 10 ] 二.UIView常见方法 1.addSubview 添加子控件,被添加到最上面(subviews中的最后面) 2.removeFromSuperview 从父控件中移除 3.viewWithTag: 父控件可以根据这个tag 标识找到对应的控件(遍历所有的子控件) 4.insertSubview:atIndex: 添加子控件到指定的位置 5.利用两个类方法来执行动画的两个方法 +(void) beginAnimations:(NSString *)animationID context:(void *)context; /**..需要执行动画的代码..**/ +(void) commitAnimations; 6.利用blok 执行动画 /* duration 动画持续时间 animations 存放需林执行动画的代码 completion 存放动画完毕后需要执行的操作代码 */ + (void) animateWithDuration:(NSTimeInterval) duration animations:(void (^)(void))animations completion:(void(^)) (BOOL finished) completion 三.UIControl 1.只要继承UIControl ,就能简单地处理事件(点击事件,值改变事件) 2.继承了UIControl的子类 UIButton.UISlider.UISwitch .UIDatePicker 等等 3.当需要监听了一个子控件时间的时候,解决步骤: 1>.先看它是否继承自UIControl 2>.再看它内部是否有delegate属性 4.常用属性 1>enabled 能否处理时间 2>contentVerticalAlignment 内容在垂直方向上的排布方式 3>contentHorizontalAlignment 内容在水平方向上的排布方式 5.常用方法 1> 添加监听器 /* target 监听器对象 action 事件触发时所调用的方法,调用target的方法 */ -(void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents; 2> 删除监听器 //删除监听器后,事件触发时就不会再通知监听器了,也就不会再调用target的action方法了 -(void roemoveTarget:(id)target action:](SEL)action forControlEvents:](UIControlEvents) controlEvents); 3>