zoukankan      html  css  js  c++  java
  • AutoLayout(转)

      

    转自    http://blog.sina.com.cn/s/blog_9564cb6e0101wv9o.html

    controller和View的责任分配:

    1、View指定固有的content size

    leaf-level views,比如buttons相比分配位置的代码,它自己更应该知道它自己size是多大。intrinsicContentSize,告诉layout system在一个视图内有一些内容它并不了解;这个方法在子类中被重写,被layout system调用。一个View可返回它的宽高或者NSViewNoInstrinsicMetric

    2、Controller 指定intrinsic多重要

    尽管一个View指定了它的固定content size,这个View的使用者会说intrinsic多重要.setContentHuggingPriority:forOrientation:   setContentCompressionResystancePriority:forOrientation:

    3、如果实现了一个自定义View:1)updateConstraints  2)layout

     

    setTranslatesAutoresizingMaskIntoConstraints: view的autoresing Mask是否需要被翻译成constriants.因为通常情况下view的autoresing mask产生的constraints完全指定了view的位置,如果想要constraints更加灵活,必须忽略autoresingMask,既NO。IB创建的视图已经设置为NO。

     

    Visual Format Language

    1、standard space: [button]-[textField]

    2、width constraint :[button(>=50)]

    3、Connection to superView : |-50-[orchbox]-50-|

    4、Vertical Layout: V:[topField]-10-[bottomField]

    5、Flush Views:[maroonView][oceanView]

    6、Priority:[button(100@20)]

    7、Equal Width:  [button1(==button2)]

    8、Multple predicates: [flexibleButton(>=70,<=90)]

     

    NSLayoutFormatOptions

    NSLayoutFormatAlignAllLeft  = NSLayoutAttributeLeft  对象的标准矩形区域左侧

    NSLayoutFormatAlignAllRight = NSLayoutAttributeRight 对象的标准矩形区域右侧

    NSLayoutFormatAlignAllTop = NSLayoutAttributeTop  对象的标准矩形区域上侧

    NSLayoutFormatAlignAllBottom = NSLayoutAttributeBottom  对象的标准矩形区域下侧

    NSLayoutFormatAlignAllLeading = NSLayoutAttributeLeading  对象的标准矩形区域前沿

    NSLayoutFormatAlignAllTrailing = NSLayoutAttributeTrailing 对象的标准矩形区域末尾

    NSLayoutFormatAlignAllCenterX = NSLayoutAttributeCenterX 对象的标准矩形区域x轴中点

    NSLayoutFormatAlignAllCenterY = NSLayoutAttributeCenterY 对象的标准矩形区域y轴中点

    NSLayoutFormatAlignAllBaseLine = NSLayoutAttributeBaseLine  对象的baseline

     

    setContentHuggingPriority:forOrientation:   在指定方向上,view反对超过它的固定大小,NSLayoutPriorityDefaultLow,NSLayoutPriorityDefaultHight

     

    setContentCompressionResistancePrioriry:Orientation:  在指定方向上,view小于它的固定大小的抵抗优先级

     

    NSLayoutPriority :  

    NSLayoutPriorityRequired  1000   ;

    NSLayoutPriorityDefaultHigh  750  button不压缩它的内容;

    NSLayoutPriorityDragThatCanResizeWindow 510;

    NSLayoutPriotiryWindowSizeStayPut 500  窗口大小保持不变,实际上你希望比它大或小;

    NSLayoutPriorityDragCannotResizeWindow  490  splite view拆分,拖动不改变窗口大小;

    NSLayoutPriorityDefaultLow 250 一个button水平包含它的内容;

    NSLayoutPriorityFittingSizeCompression 50;

     

     

    requiresConstraintBasedLayout   自定义view应该重写这个方法返回YES,如果它不能使用autoresing正确的布局

  • 相关阅读:
    Selenium(三)webdriver的API与定位元素
    代码验证和动手动脑
    课程作业01实验报告1,2,3
    动手动脑
    课程作业03实验报告
    课程作业02实验报告
    猜数字实验报告
    java各种问题总结和一些讨论
    java从命令行接受多个数字并求和
    java登陆界面实验报告
  • 原文地址:https://www.cnblogs.com/A--G/p/4667953.html
Copyright © 2011-2022 走看看