AutoLayout

  1. AutoLayout是一种基于约束的,描述性的布局系统。
    程序员—-(cgrect)—>frame(center+bounds)    =====>   程序员—(NSLayoutConstraint)—>AutoLayout—(cgrect)—>center+bounds
  2. Autolayout 基本使用方法
    1. interfaceBuilder
      1. Alignment Constraints
      2. custom Constraints
      3. Spacing to nearest neighbor  这个是系统自己选定的 依据是 interfacebuilder 现有的状态  多层布局时会有很多麻烦(目前不知道 解决办法)
      4. Constraint to margins iOS8 添加的新特性(左右16) .苹果UI引导方向
      5. Layout Guide

        用于适配 iOS7 以前的版本 和以后版本的差异 ,主要原因 是 iOS7以后navigationController 的controller.view 的大小与navigation.view的大小相同 layout Guide 用于辅助布局
      6. Align

        对齐方式  主要针对文字的对齐
    2. 编码NSlayoutContrainst
      1. 模型:  item1.attribute = multiplier ⨉ item2.attribute + constant
    3. 代码: [NSLayoutConstraint constraintWithItem:item1
                                       attribute:NSLayoutAttributeBottom
                                       relatedBy:NSLayoutRelationEqual
                                          toItem:item2
                                       attribute:NSLayoutAttributeBottom
                                      multiplier:1.0
                                        constant:-padding];
    4. 添加:约束要添加到View 上才能生效.View 官方推荐的View选定规则:同时包含两item的最小子树的根节点(树模型)
    5. 优先级: @property UILayoutPriority priority; 取值范围0--1000
      typedef float UILayoutPriority;
      static const UILayoutPriority UILayoutPriorityRequired NS_AVAILABLE_IOS(6_0) = 1000;
      static const UILayoutPriority UILayoutPriorityDefaultHigh NS_AVAILABLE_IOS(6_0) = 750;
      static const UILayoutPriority UILayoutPriorityDefaultLow NS_AVAILABLE_IOS(6_0) = 250;
      static const UILayoutPriority UILayoutPriorityFittingSizeLevel NS_AVAILABLE_IOS(6_0) = 50;
    6. 刷新:setNeedsUpdateConstraints和-layoutIfNeeded两个方法来刷新约束的改变.
    7. 内置大小(受view内容的影响view必须有多大空间才可以) 例如:UILabel(文字)
      UILabel NSTextfield 有一个preferredMaxLayoutWidth 属性用来处理内置大小
      代码:@implementation MyLabel - (void)layoutSubviews{ self.preferredMaxLayoutWidth = self.frame.size.width; [super layoutSubviews];} @end - (void)layoutSubviews{
              [self invalidateIntrinsicContentSize];
          [super layoutSubviews]; } - (CGSize)intrinsicContentSize{
          return (...); } - (void)viewDidLayoutSubviews{ [super viewDidLayoutSubviews]; myLabel.preferredMaxLayoutWidth = myLabel.frame.size.width; [self.view layoutIfNeeded]; }
    8. Visual Format Language 可视化格式语言

      Apple 为减少程序员的工作量 推出的约束快速生成 技术
      1. 代码: 
            UIButton *cancelButton = ...;
            UIButton *acceptButton = ...;
            viewsDictionary = NSDictionaryOfVariableBindings(cancelButton,acceptButton);
            [NSLayoutConstraint constraintsWithVisualFormat:@"[cancelButton]-[acceptButton]"
                                                    options:0
                                                    metrics:nil
                                                      views:viewsDictionary];
      2. 多种方式:
        1. [cancelButton(72)]-12-[acceptButton(50)]
        2. 所有出现数字的地方 多可以添加关系比如 [cancelButton(>=72)]-(12)-[acceptButton(50)]
        3. 可以添加优先级 用关键字符@  比如 [cancelButton(>=72@1000)]-(12)-[acceptButton(50)]
        4. 可以用名称标示相等  比如 [cancelButton(>=72@1000)]-(12)-[acceptButton(==cancelButton)]
        5. 用V:  H: 标示 后面语句定义的方向  用 | 标示 Constraints挂载View的边界
      3. 缺陷:
        1. 不能标示倍数
        2. 不能表示对齐
    9. Masonry: 野区推出的简化框架
      例子: [label makeConstraints:^(MASConstraintMaker *make) {
                          make.left.equalTo(self).offset(@(left));
                          make.top.equalTo(rtLabel0.bottom).offset(@0);
                          make.width.equalTo(@(size.width+3 ));
                          make.height.equalTo(@(size.height));
                      }];
      1. relationship:   .equalTo equivalent to NSLayoutRelationEqual

        .lessThanOrEqualTo equivalent to NSLayoutRelationLessThanOrEqual

        .greaterThanOrEqualTo equivalent to NSLayoutRelationGreaterThanOrEqual

      2. Attribute : MASViewAttribute         NSLayoutAttribute
                   view.mas_left            NSLayoutAttributeLeft
                   view.mas_right           NSLayoutAttributeRight
                   view.mas_top NSLayoutAttributeTop
                   view.mas_bottomNSLayoutAttributeBottom
                   view.mas_leadingNSLayoutAttributeLeading
                   view.mas_trailingNSLayoutAttributeTrailing
                   view.mas_widthNSLayoutAttributeWidth
                   view.mas_heightNSLayoutAttributeHeight
                   view.mas_centerXNSLayoutAttributeCenterX
                   view.mas_centerYNSLayoutAttributeCenterY
                   view.mas_baselineNSLayoutAttributeBaseline
      3. 内部简化 : //these two constraints are exactly the same
                   make.left.greaterThanOrEqualTo(label);
                   make.left.greaterThanOrEqualTo(label.mas_left);
      4. NSNumber : make.top.equalTo(rtLabel0.bottom).offset(@0);
      5. NSArray  :  make.height.equalTo(@[label.mas_height, rtLabel.mas_height]);
                    make.height.equalTo(@[label, rtLabel]);
                    make.left.equalTo(@[label, @100, rtLabel.right]);
      6. 优先级    :  make.left.greaterThanOrEqualTo(label.mas_left).with.priorityLow();
                    make.top.equalTo(label.mas_top).with.priority(600);
      7. MASCompositeConstraints : 扩展了对 edge size center 的支持
      8. 总之masonry 使得约束实现 简单直观
    10. autoLayout性能

      图中为性能对不图  横轴 View的个数 纵轴 ms

      平行view结构 和深度view结构 对比

      在平行View结构 和 深度 View结构 添加 与移动对比
  3. size class iOS 8 为了适配多尺寸的iOS设备推出的技术

    形成9种选择  最简单的理解就是 storyboard 以前就是一个 现在9个了  几乎所有多屏尺寸相关的 设置 都与size class 相关

    1. 开关 : 

      苹果技术再牛  我们可以不用
    2. 合并与分离关系  我们之前说过 storyboard 有9个  都编辑很累的
      1. 在 any Width|Any Height 下的操作是同时编辑9个 storyboard
      2. 在任一个 为Any 时 同时编辑 三个
      3. 只有四种情况 特定编辑一个
    3. 约束编辑界面  属性前面出现了+号
    4. font 属性前面出现了+号
  4. 总结 UI设计 发展是越来越专业 而且 apple 追求智能化 多样化 UI 独立

IOS UI 设计 技术的更多相关文章

  1. UI设计技术分享:教你几个设计技巧让老板对你的设计赞不绝口

    我们做任何设计都离不开大小与重复的运用,这样能使我们的设计更加理性和科学,经得起推敲,那么我们一起来探讨下如何在产品设计中运用这一方法. 为什么大的物体更吸引眼球    ▲如上图所示,a球会比右边b球 ...

  2. [iOS UI设计笔记整理汇总]

    8.UIsearchbar放到Navigationbar 上(意思是建个View作为titleview) //此处调用的是第三方封装的SearchBar,也可以自定义. self.searchBarW ...

  3. iOS UI 设计

    优设 http://www.uisdc.com Sketch http://www.sketchcn.com

  4. 最意想不到的5个APP UI 设计范例

    现如今,智能手机已成为人们生活中不可或缺的一个物件,琳琅满目的手机APP充斥着各大应用市场.对于普通人来说,他们的衣食住行因此而变得简单方便:对设计师们来说,他们则面临更多的机遇和挑战.每位设计师都梦 ...

  5. [读书笔记]iOS 7 UI设计 对比度

    好久没写随笔了,最近在读<iOS 7 byTutorials>,很不错,推荐给大家. 每一个好的程序员也都是一个设计师,不懂设计的程序员不是好的CTO.哈哈,开个小玩笑. iOS 7设计的 ...

  6. iOS 11 APP 设计中的几个 UI 设计细节

    Apple 官网看了 iOS 11 的介绍,发现有不少的更新哦,比如控制中心.Siri.Live Photo 等等,总体来说都有很多不错的体验,不过本文不介绍功能,只说视觉界面. 在 iOS 11 的 ...

  7. 缩放因子和UI设计

    一.PPI 1.像素密度PPI:PPI(Pixel Per Inch by diagonal):表示沿着对角线,每英寸所拥有的像素(Pixel)数目. 根据勾股定理(直角三角形两边为a和b,斜边为c, ...

  8. 分享20个最新的免费 UI 设计素材给设计师

    用户界面设计涉及到很多的创意,灵感以及需要与客户进行有效沟通的技能.良好的用户界面是一致的,可以使网站更容易理解和使用.UI设计的重点在于用户体验和互动,同时易于使用对于一个成功的移动应用程序来说非常 ...

  9. 设计人员应该看的15个很酷的 iOS 8 设计

    苹果新一代智能手机 iPhone 6 发布已经有一段时间了,一些创意设计师已经开始在设计中采用 iOS 8 设计理念.当然,其中有些是对于未来的展望和大胆的设计.我在这里收集了15个很酷的 iOS 8 ...

随机推荐

  1. 大数据学习——mapreduce案例join算法

    需求: 用mapreduce实现select order.orderid,order.pdtid,pdts.pdt_name,oder.amount from orderjoin pdtson ord ...

  2. 一个爬取lativ诚衣网站上模特穿搭图片的爬虫

    show the code: [peter@localhost savvy]$ vi lativ.py # -*- coding:utf-8 -*- import requests,lxml,os f ...

  3. 【2018 Multi-University Training Contest 3】

    01:https://www.cnblogs.com/myx12345/p/9420198.html 02: 03: 04:https://www.cnblogs.com/myx12345/p/940 ...

  4. hdu 2438 Turn the corner [ 三分 ]

    传送门 Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  5. Method, apparatus and system for acquiring a global promotion facility utilizing a data-less transaction

    A data processing system includes a global promotion facility and a plurality of processors coupled ...

  6. c/s程序版本自动升级的问题,如何判断client端版本号是否最新,然后从指定ftp服务器down

    c/s程序版本自动升级的问题,如何判断client端版本号是否最新,然后从指定ftp服务器down http://blog.csdn.net/delphizhou/article/details/30 ...

  7. POJ 1015 Jury Compromise【DP】

    罗大神说这题很简单,,,,然而我着实写的很难过... 题目链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=110495#proble ...

  8. BZOJ4555求和(cdq分治+NTT)

    题意: 输出f(n)对998244353(7 × 17 × 223 + 1)取模的结果.1 ≤ n ≤ 100000 其中S(i,j)是第二类Stirling数,即有i个球,丢到j个盒子中,要求盒子不 ...

  9. springboot 第一个程序

    idea --> new project --> 选择Spirng Initializr --> next 傻瓜式操作  --> 添加web依赖 项目基本结构: 创建contr ...

  10. [转] Oracle数据库维护常用SQL语句集合

           原文地址 进程相关: 1. 求当前会话的SID,SERIAL# SELECT Sid, Serial# FROM V$session WHERE Audsid = Sys_Context ...