UI知识点

/* UIView * redView = [[UIView alloc] initWithFrame:CGRectMake(20, 50, 100, 100)];
    
    redView.backgroundColor = [UIColor redColor];
    
    NSLog(@"%.f",redView.center.x);
    
    NSLog(@"%.f", redView.center.y);
    
    [_window addSubview:redView];
    
    [redView release];
    
    UIView * blueView = [[UIView alloc] initWithFrame:CGRectMake(30, 40, 50, 50)];
    
    
    blueView.backgroundColor = [UIColor blueColor];
    
    blueView.center = CGPointMake(40, 50);
    
    [redView addSubview:blueView];
    
    [blueView release];
    
    UIView * greenView = [[UIView alloc] initWithFrame:CGRectMake(40, 130, 100, 100)];
    
    greenView.backgroundColor = [UIColor greenColor];
    
    [_window insertSubview:greenView atIndex:0];
    
    [greenView release];
    
    UIView  * grayView = [[UIView alloc] initWithFrame:CGRectMake(40, 90, 60, 60)];
    
    grayView.backgroundColor = [UIColor grayColor];
    
    //[greenView insertSubview:grayView aboveSubview:greenView];在绿视图上面添加子视图
    
    [greenView insertSubview:grayView belowSubview:greenView];//在绿视图下面添加子视图
    
    [grayView release];*///视图的frame和center、bounds的关系
    
    /*UIView * aView = [[UIView alloc]initWithFrame:CGRectMake(20, 40, 100, 100)];
    
    aView.backgroundColor = [UIColor orangeColor];
    
    [_window addSubview:aView];
    
    [aView release];
    
    UIView * bView = [[UIView alloc] initWithFrame:CGRectMake(130, 40, 100, 100)];
    
    bView.backgroundColor = [UIColor greenColor];
    
    [_window addSubview:bView];
    
    [bView release];
    
    UIView * cView = [[UIView alloc]initWithFrame:CGRectMake(90, 140, 100, 100)];
    
    cView.backgroundColor = [UIColor cyanColor];
    
    [_window insertSubview:cView atIndex:1];//把cView插在aView和bView之间
    
    [cView release];
    
    UIView * dView = [[UIView alloc]initWithFrame:CGRectMake(30, 40, 50, 50)];
    
    dView.backgroundColor = [UIColor redColor];
    
    [aView insertSubview:dView aboveSubview:aView];//把dView添加在aView上面
    
    [dView release];
    
    UIView * eView = [[UIView alloc] initWithFrame:CGRectMake(130, 40, 50, 50)];
    
    eView.backgroundColor = [UIColor yellowColor];
    
    [bView insertSubview:eView belowSubview:bView];//把eView添加在bView下面
    
    [eView release];*///添加视图的方法
   /* UIView * aView = [[UIView alloc]initWithFrame:CGRectMake(20, 40, 100, 100)];
    
    aView.backgroundColor = [UIColor orangeColor];
    
    [_window addSubview:aView];
    
    [aView release];
    
    UIView * bView = [[UIView alloc] initWithFrame:CGRectMake(130, 40, 100, 100)];
    
    bView.backgroundColor = [UIColor greenColor];
    
    [_window addSubview:bView];
    
    [bView release];
    
    UIView * cView = [[UIView alloc]initWithFrame:CGRectMake(90, 40, 100, 100)];
    
    cView.backgroundColor = [UIColor cyanColor];
    
    [_window insertSubview:cView atIndex:1];//把cView插在aView和bView之间
    
    [cView release];
    
    UIView * dView = [[UIView alloc]initWithFrame:CGRectMake(30, 40, 50, 50)];
    
    dView.backgroundColor = [UIColor redColor];
    
    [aView insertSubview:dView aboveSubview:aView];//把dView添加在aView上面
    
    [dView release];
    
    UIView * eView = [[UIView alloc] initWithFrame:CGRectMake(130, 40, 50, 50)];
    
    eView.backgroundColor = [UIColor yellowColor];
    
    [bView insertSubview:eView belowSubview:bView];//把eView添加在bView下面
    
    [eView release];
    
    //[_window bringSubviewToFront:aView];//把aView视图移动最前面
    
    //[_window sendSubviewToBack:bView];//把bView视图移动最后面
    
    [_window exchangeSubviewAtIndex:1 withSubviewAtIndex:2];//交换两个指定索引位置的子视图
    
    [cView removeFromSuperview];//把dView从父视图上移除
    *///管理视图层次
    
   /* UIView * view = [[UIView alloc] initWithFrame:CGRectMake(20, 40, 100, 100)];
    
    view.backgroundColor = [UIColor blueColor];
    
    view.hidden = NO;//控制视图的显隐,YES是隐藏,NO是显示(默认)
    
    view.alpha = 0.5;//控制视图的不透明度(子视图也一起透明),取值范围0.0~1.0
    
    [_window addSubview:view];
    
    view.tag = 100; //给视图添加标记
    
    [view release];
    
    UIView * redView = [[UIView alloc] initWithFrame:CGRectMake(121, 40, 100, 100) ];
    
    redView.backgroundColor = [UIColor redColor];
    
    [view addSubview:redView];
    
    [redView release];
    
    NSLog(@"%@", redView.superview); //获取本视图的父视图
    
    NSLog(@"%@", view.subviews); //获取本视图的所有子视图
    
    NSLog(@"%@", [_window viewWithTag:100]); //取出被标记的视图
    
    */ //视图重要属性
    
   /* UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(20, 40, 200, 40)];
    
    label.text = @"梦瑶,上有天堂,下有苏杭;书中自有黄金屋,书中自有颜如玉。"; //显示的文本内容
    
    label.textColor = [UIColor blueColor]; //文本内容颜色
    
    label.font = [UIFont fontWithName:@"Papyrus" size:12];//文体字体和字体大小
    
    NSLog(@"%@", [UIFont familyNames]);//输出系统中所有的字体
    
    label.textAlignment = NSTextAlignmentRight; //对齐方式,枚举类型
    
    label.lineBreakMode = NSLineBreakByWordWrapping; //换行 枚举类型
    
    label.numberOfLines = 3; //行数
    
    label.shadowColor = [UIColor redColor]; //阴影颜色
    
    label.shadowOffset = CGSizeMake(2, -5); //阴影大小
    
    [_window addSubview:label];
    
    [label release];*/ //控制文本显示的属性

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值