zoukankan      html  css  js  c++  java
  • UI基础 UIView

    app m

    #import "AppDelegate.h"
    #import "ViewController.h"
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        ViewController* first=[[ViewController alloc]init];
        self.window.rootViewController=first;
        
     
        return YES;
    }

    UIView m

    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    //    self.view.backgroundColor=[UIColor orangeColor];
        //UIView 屏幕上的一块巨型区域
        //UIView
        //1.初始化View
        UIView* view1 =[[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
        //2.设置view的背景色
        view1.backgroundColor=[UIColor greenColor];
        //3.添加
        [self.view addSubview:view1];
        NSLog(@"%@",self.view);
        
        UIView* view2=[[UIView alloc]initWithFrame:CGRectMake(200, 300,  100, 100)];
        view2.backgroundColor=[UIColor blueColor];
        [self.view addSubview:view2];
        
        //UI View常用的属性
        //1.透明度(0-1)
        view1.alpha=1;
        view2.alpha=1;
        //2.是否隐藏
        view1.hidden=NO;
        //3.中心点
        view1.center=self.view.center;
        //4.tag (标签) 值
        view1.tag=99;
        // 根据编号找到这个view
        UIView* resltView = [self.view viewWithTag:99];
        resltView.backgroundColor=[UIColor redColor];
        
        // 将一个子视图放在 前面 resltView
        [self.view bringSubviewToFront:resltView];
        // 将一个视图移动到 后面
        [self.view sendSubviewToBack:resltView];
        // 子视图 自杀
        [view1 removeFromSuperview];
        
    
    }
  • 相关阅读:
    EL表达式判断
    java反射机制,通过类名获取对象,通过方法名和参数调
    MYSQL删除重复数据
    centos apache 隐藏和伪装 版本信息
    CentOS安装crontab及使用方法
    Samba出现“您可能没有权限使用网络资源”解决方法
    Idea使用备忘
    Jenkins入门教程
    multiple datasource config
    windows环境下PostgreSQL的安装
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13296229.html
Copyright © 2011-2022 走看看