zoukankan      html  css  js  c++  java
  • UISB UIVIew基础

    ViewContriller.m

    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    
    
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        
        //创建一个UIView 对象
        // UIVIew是 IOS视图对象
        // 显示在我们屏幕上的所有的对象基础
        //所有显示在屏幕上的对象都是继承于UIView
        //所有屏幕上能看到的对象都是UIView的子类
        //UIView是一个矩形对象 有层级关系
        UIView* view = [[UIView alloc]init];
        //设置UIVIew的位置
        view.frame =CGRectMake(100, 200, 100, 100);
        view.backgroundColor=[UIColor greenColor];
        
        //将我们新建的视图添加到父亲视图上
        //1.将我们新建视图显示到屏幕上
        //2.将视图作为父亲视图的子视图管理起来
        [self.view addSubview:view];
        
        //是否隐藏视图对象
        //YES 隐藏 NO 显示
        view.hidden=NO;
        
        //设置视图的透明度
        //alpha 1 不透明
        //alpha 0 透明
        //alpha 0.5 半透明,
        
        view.alpha=0.5;
        
        //设置是否显示不透明,
        view.opaque=NO;
        //将自己从父亲视图删除掉
        //1.从父亲视图管理中删除
        //2.不会显示在屏幕
        [view removeFromSuperview];
        
        
        
        
    }
    
    
    @end

    UIView 层级关系

    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        UIView* view01=[[UIView alloc]init];
        view01.frame=CGRectMake(100, 100, 150, 150);
        view01.backgroundColor=[UIColor blueColor];
        
        
        UIView* view02=[[UIView alloc]init];
        view02.frame=CGRectMake(125, 125, 150, 150);
        view02.backgroundColor=[UIColor orangeColor];
        
        UIView* view03=[[UIView alloc]init];
        view03.frame=CGRectMake(150, 150, 150, 150);
        
        view03.backgroundColor=[UIColor greenColor];
        
        //将三个视图对象显示在屏幕上
        //并添加到父亲视图上
        //哪一个视图被先填充,就先绘制哪一个视图;
        
        [self.view addSubview:view01];
        [self.view addSubview:view02];
        [self.view addSubview:view03];
        
        
        //将某一个视图调整最前面
        //参数 UIView对象 调整哪一个视图到最前方
        [self.view bringSubviewToFront:view03];
        
        //将某一个视图调整显示最后面
        [self.view sendSubviewToBack:view01];
        
        
        UIView* viewFront=self.view.subviews[2];
        UIView* viewBack=self.view.subviews[1];
        if (viewBack==view02){
            NSLog(@"相等");
            
        }
        
    //    view01.removeFromSuperview;
            
        
    }
    
    @end
  • 相关阅读:
    kafka 消息推送报错"dial tcp: lookup iZ2ze2k3******7abjcsyZ on 219.141.140.10:53: no such host"
    MacBook安装Homebrew的国内安装脚本 告别龟速下载安装
    docker info命令的使用和返回结果描述
    Python requests.post方法中data与json参数区别
    redis master-slave python switch logic (升级版,序列七)
    ELKF日志收集系统
    MySQL 中的concat函数使用
    程序员的街舞“梦”
    第一份工作没有工资,信不信
    Java中的享元设计模式,涨姿势了!
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13635846.html
Copyright © 2011-2022 走看看