UIView

1.创建一个视图

  UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(50, 10, 200, 200)];

2.设置视图的背景颜色

  [redView setBackgroundColor:[UIColor redColor]];

  redView.backgroundColor = [UIColor redColor];

3.将一个视图添加到另一个视图的时候,就有子视图和父视图之分,后面添加的视图会在之前的视图之上(覆盖)

4.设置透明度 0 - 1

  redView.alpha = 1;

  父视图透明子视图也透明,子视图的透明度是在父视图透明度之上

5.添加一个tag

     redView.tag = 2016;

6.让这个视图的所有子视图中,凡是越界了(超过我的显示范围),截取掉越界的部分

     redView.clipsToBounds = YES;

7.将这个视图添加到界面中(让这个视图作为根视图的子视图)

     [self.view addSubview:redView];

8.将视图删掉

     [blueView removeFromSuperview];

9.ios坐标系

  以左上角为坐标原点,向右边是x的正方向,向下是y的正向方

  bounds: 相对于视图本身而言(0,0,w, h)

  frame:相对于父视图的坐标

  center: 相对于父视图的中心点坐标

10.在一个界面里面获取一个视图的方式

  如果有属性变量保存这个视图对象,那么直接使用属性访问

  可以通过tag来访问某一个对象 viewWithTag

  可以通过视图的层级

11.使用图片作为view的背景

    //创建一个UIView

    self.dotView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 52, 52)];

    //获取图片

    UIImage *dotImage = [UIImage imageNamed:@"Unlock_DotLock1_Selected"];

    //使用图片作为视图的背景颜色

    _dotView.backgroundColor = [UIColor colorWithPatternImage:dotImage];

    [self.view addSubview:self.dotView];

12.userinterfaceEnable =YES可以交互,NO不可以交互

13.imageView的效果 

  self.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageWithName:@"XXX"]];

原文地址:https://www.cnblogs.com/huoran1120/p/5100330.html