UIView
// 1.初始化一个
UIView
对象
// UIView *view = [UIView alloc]
初始化方法];
// 2.设置UIView的属性
例如:颜色;
// 3.把UIView(视图)
加载到窗口上;
// 4.释放对象
UIView
*aView = [[UIView
alloc]
initWithFrame:
initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)];
aView.backgroundColor = [UIColor
redColor];
[superView
addSubview:aView];
[aView
release];
//设置背景颜色
如果没有给UIView设置背景颜色,默认的颜色是透明的;
View.backgroundColor
= [UIColor
yellowColor]
//将坐标变为字符串
NSStringFromCGPoint(<#CGPoint point#>)
//利用tag值
取出视图
view2.tag
=
1000 ;
//必须提前给视图加上tag值(别名);
UIView *tagView = [view
viewWithTag:1000];
//把父视图上的某个子视图
[view insertSubview:view3 atIndex:0];//移动到指定位置
[view insertSubview:view3 atIndex:1];
[view insertSubview:view2 aboveSubview:view3];//移动到...上方
[view insertSubview:view2 belowSubview:view3];//移动到...下方
//bounds, 默认的起始点是0,0 宽,高与frame相同;
//改变父视图的bounds
/*
1.子视图的坐标系
2.父视图没有变化
3.换来的坐标系(0,0)点改变,例如(10,10)即改变bounds
4.寻找现在的(0,0)点(原点)
5.子视图根据新的坐标原点发生变化
[view insertSubview:view3 atIndex:0];//移动到指定位置
[view insertSubview:view3 atIndex:1];
[view insertSubview:view2 aboveSubview:view3];//移动到...上方
[view insertSubview:view2 belowSubview:view3];//移动到...下方
//bounds, 默认的起始点是0,0 宽,高与frame相同;
//改变父视图的bounds
/*
1.子视图的坐标系
2.父视图没有变化
3.换来的坐标系(0,0)点改变,例如(10,10)即改变bounds
4.寻找现在的(0,0)点(原点)
5.子视图根据新的坐标原点发生变化
*/
//如果该视图被隐藏,其子视图也全部被隐藏.
//view2.hidden = YES;
//设置透明度, alpha 范围 0 - 1 ;
//1是不透明,依次递减;
//view3.alpha = 0.5;
//view2.alpha = 0.5;
//设置透明度, alpha 范围 0 - 1 ;
//1是不透明,依次递减;
//view3.alpha = 0.5;
//view2.alpha = 0.5;
//view.alpha = 0.5;
UILabel
//创建一个UILabel;
/*
1.初始化
2.设置属性
3.添加显示
4.释放对象
*/
// UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 500, 500)];
/*
1.初始化
2.设置属性
3.添加显示
4.释放对象
*/
// UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 500, 500)];
// label.backgroundColor = [UIColor blackColor];
// label.text = @"Application windows are expected to have a root view controller at the end of application launch”;
//设置文本消息
// label.textColor = [UIColor yellowColor];//文本颜色
// label.textAlignment = NSTextAlignmentCenter;//对齐方式
//
// //如果想有多少显示多少就给0
// label.numberOfLines = 0;
// label.shadowColor = [UIColor redColor];
// label.shadowOffset = CGSizeMake(-3, -3);
// label.font = [UIFont systemFontOfSize:20];
// //打印已安装的字体
//// NSArray *fontArray =[UIFont familyNames];
//// for (NSString *name in fontArray) {
//// NSLog(@"%@",name);
//// }
// //设置字体
// label.font = [UIFont fontWithName:@"Zapfino" size:30];
////
// //设置断行
//
// //如果想有多少显示多少就给0
// label.numberOfLines = 0;
// label.shadowColor = [UIColor redColor];
// label.shadowOffset = CGSizeMake(-3, -3);
// label.font = [UIFont systemFontOfSize:20];
// //打印已安装的字体
//// NSArray *fontArray =[UIFont familyNames];
//// for (NSString *name in fontArray) {
//// NSLog(@"%@",name);
//// }
// //设置字体
// label.font = [UIFont fontWithName:@"Zapfino" size:30];
////
// //设置断行
// //label.lineBreakMode = NSLineBreakByTruncatingHead;