黑马程序员技术交流社区

标题: uiview [打印本页]

作者: holmesconan    时间: 2015-12-28 00:10
标题: uiview
UIView的初始化方法:
- (id)initwithframe:(CGRect)frame

参数frame是一个CGrect类型变量的结构体,CGRect包含origin和size两个成员变量。分别代表视图的位置和尺寸。

frame:相对父视图的位置和大小(CGRect)
bounds:相对自己的位置和大小(CGRect)
center:相对父视图的中心点 (CGPoint)
transform:变换属性(CGAffineTransform)
superview:父视图
subviews:子视图
window:当前View所在的window
backgroundColor:背景颜色(UIcolor)
alpha:透明度(CGfloat)
hidden:是否隐藏(bool)
userInteractionEnabled:是否开启交互
tag:区分标识(NSinteger)
layer:视图层(CAlayer)


- (void)removefromsuperview;//从父视图中移除
- (void)addSubview:(UIView*)view;//添加一个子视图
- (void)bringSubviewToFront:(UIView)view;//将某个子视图移至最上方显示
- (BOOL)isDescendantOfview:(UIView)view;//判断一个view是否为子view
- (UIView *)viewWithTag:(NSInteger)tag;//取到指定TAG值的view

设置cliptoBounds属性让产出父视图的部分不显示
新建一个视图
firstview *view1 = [[firstview alloc]initWithFrame:self.window.frame];

view1.BackgroundColor = [UIColor redColor]

[self.window addSubview:view1]:     (retaincount    +1)

[view1 release]              ( removeFromSuperview     -1 )

屏幕变成红色





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2