A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© holmesconan 中级黑马   /  2015-12-28 00:10  /  520 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

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 )

屏幕变成红色

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马