1 //
 2 //  ViewController.m
 3 //  IOS_0115_buzhi
 4 //
 5 //  Created by ma c on 16/1/15.
 6 //  Copyright (c) 2016年 博文科技. All rights reserved.
 7 //
 8
 9 #import "ViewController.h"
10
11 @interface ViewController ()
12 @property (nonatomic, strong) UIView *myView;
13
14
15 @end
16
17 @implementation ViewController
18
19 - (void)viewDidLoad {
20     [super viewDidLoad];
21
22     UIView *blue = [[UIView alloc] init];
23     blue.frame = CGRectMake(0, 0, 200, 200);
24     blue.backgroundColor = [UIColor blueColor];
25     [self.view addSubview:blue];
26     self.myView = blue;
27
28     UIView *red = [[UIView alloc] init];
29     red.backgroundColor = [UIColor redColor];
30     red.frame = CGRectMake(0, blue.frame.size.height-50, blue.frame.size.width, 50);
31     [blue addSubview:red];
32
33     UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
34     [btn setFrame:CGRectMake(self.view.center.x - 50, self.view.center.y + 150, 50, 50)];
35     [btn setBackgroundColor:[UIColor purpleColor]];
36
37     [self.view addSubview:btn];
38
39     [btn addTarget:self action:@selector(change) forControlEvents:UIControlEventTouchUpInside];
40
41     //设置autoresizing(前提取消autolayout)
42     //设置显示规则,只能按照父控件来设置参照
43     red.autoresizingMask = UIViewAutoresizingFlexibleTopMargin |UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
44
45     /*
46      位枚举
47      UIViewAutoresizingNone                 = 0,
48      UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,距离父控件的右边是固定的
49      UIViewAutoresizingFlexibleWidth        = 1 << 1,宽度随着父控件变化而变化
50      UIViewAutoresizingFlexibleRightMargin  = 1 << 2,距离左边是固定的
51      UIViewAutoresizingFlexibleTopMargin    = 1 << 3,距离下边是固定的
52      UIViewAutoresizingFlexibleHeight       = 1 << 4,高度随着父控件变化而变化
53      UIViewAutoresizingFlexibleBottomMargin = 1 << 5距离上面是固定的
54
55      Autoresizing的弊端
56      在storyboard中演示一个blueView左边和底部与父控件间距固定20,高为50
57      右边有一个redView它的右边和底部与父控件间距也是固定为20
58      两个View等宽,等高,
59      redView离blueView之间的间距永远是20.演示不能做出这个效果,然后引入Auto Layout
60
61      */
62 }
63
64 - (void)change
65 {
66     CGRect frame = self.myView.frame;
67     frame.size.width +=20;
68     frame.size.height +=20;
69     self.myView.frame = frame;
70
71 }
72
73 - (void)didReceiveMemoryWarning {
74     [super didReceiveMemoryWarning];
75     // Dispose of any resources that can be recreated.
76 }
77
78 @end

iOS UI-自动布局(Autoresizing)相关推荐

  1. IOS UI开发基础之超级猜图完整版本-08

    IOS UI开发基础之超级猜图完整版本-08 // // ViewController.m // 09-超级猜图 // // Created by 鲁军 on 2021/1/31. //#import ...

  2. iOS UI 开发按钮的使用

    IOS UI 开发之按钮的使用 // // ViewController.m // 02按钮的使用介绍 // // Created by 鲁军 on 2021/1/26. //#import &quo ...

  3. 基于 KIF 的 iOS UI 自动化测试和持续集成

    客户端 UI 自动化测试是大多数测试团队的研究重点,本文介绍猫眼测试团队在猫眼 iOS 客户端实践的基于 KIF 的 UI 自动化测试和持续集成过程. 一.测试框架的选择 iOS UI 自动化测试框架 ...

  4. IOS UI Automation 学习之常用类,方法和模拟手势

    为什么80%的码农都做不了架构师?>>>    IOS UI Automation 学习之常用类,方法和模拟手势 常用类结构图 作者不擅长作画,如果有好的画此类图形的工具,可以留言, ...

  5. android 布局可大可小,UI设计教程之:ios与android ui适配(将IOS UI转换成Android经验畅谈)...

    内容提要:这是UI设计系列教程之ios与android ui适配经验畅谈.文章作者介绍了自己将IOS UI转换成Android经验,包括:不要直接转换.了解单位和组件缩放格式.屏幕尺寸DP和像素的换算 ...

  6. ios ui自动化测试_Xcuitest的ios自动化ui测试

    ios ui自动化测试 Who knew automated UI Testing could be so easy! Well, I guess Apple did. Automated UI Te ...

  7. iOS UI 之聊天室渐变蒙层效果

    iOS UI 开发中,我们已接触过不少 layer 相关设置,如常见设置按钮的圆角效果 UIButton *button = [UIButton buttonWithType:UIButtonType ...

  8. 控件的基本使用-iOS—UI笔记

    学习目标 1.[掌握]第一个UI项目 2.[掌握]控件连线 3.[掌握]按钮的基本操作 4.[掌握]控件的常用属性 一.第一个UI项目 UI (User Interface)也是就用户界面,是App的 ...

  9. 关于Facebook iOS UI 工具ComponentKit简介

    在 iOS 上面开发界面,需要创建视图.配置界面.视图分层等等很多步骤,也就不可避免的需要书写 N 多的代码.这还仅仅是界面设计,除此之外,完成 controllers 的回调.控制内部事务在界面上的 ...

  10. Reveal:分析iOS UI该武器

    Reveal是分析iOS应用UI的利器: Reveal可以在执行时调试和改动iOS应用程序.它能连接到应用程序,并同意开发人员编辑各种用户界面參数.这反过来会马上反应在程序的UI上.就像用FireBu ...

最新文章

  1. css布局中的居中问题
  2. Fluke OTDR新增SmartLoop双向测试功能
  3. 高薪诚聘 | 匠韵智能招聘3D视觉工程师
  4. python一千行入门代码-Python 有哪些一千行左右的经典练手项目?
  5. 【五线谱】拍号与音符时值 ( 全音符 | 二分音符 | 四分音符 | 八分音符 | 十六分音符 | 三十二分音符 )
  6. 寄娱于学第2天——PHP骰子游戏篇--优化
  7. hdu 2563
  8. 微软推出Visual Studio Kubernetes工具包预览版
  9. python中shutil模块_Python中shutil模块的学习笔记教程
  10. java amf3_Java AMF3 反序列化漏洞分析
  11. 阿里云+HCT双证认证,架构师年薪达不到25.6万全额退款
  12. UIButton 的简单运用
  13. 你是码农还是Geek?
  14. sharepoint获取当前网址
  15. linux 测试t3协议,Yealink网络电话SIP-T38G本地文件包含漏洞
  16. eclipse必备的15的个快捷键
  17. 继承ActionSupport例子展示
  18. 解决戴尔电脑禁用无线网络问题
  19. python查找相似图片
  20. realsense moveit生成octomap错误:‘Client [/move_group] wants topic /camera/color/image_raw to have dataty

热门文章

  1. python 托盘_[宜配屋]听图阁
  2. rabbitmq接口异常函数方法_[项目更新] 集成RabbitMQ队列与EventBus总线
  3. Hbase具体操作(图文并茂且超超全~~~)
  4. 怎么在html插入谷歌地图,html页面插入百度or谷歌地图
  5. [dhtmlx]group task 失效问题解决
  6. Web端调用Outlook 的发信窗口
  7. linux系统找运行指令,Linux系统常用指令总结
  8. centos7.2编译php,CentOS7.2编译安装PHP7.2.3之史上最详细步骤。
  9. rf框架搭建_Robot framework(RF)基本使用
  10. hashmap put复杂度_你碰到过几种HashMap在高并发下出现的问题,哪些可能出现的问题...