一点笔记 about layout 兼purelayout + 需要自动布局对scrollView影响

来源:互联网 发布:淘宝买的入职体检报告 编辑:程序博客网 时间:2024/06/01 13:45

文档地址

https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/

1This constraint-based approach to design allows you to build user interfaces that dynamically respond to both internal and external changes. 

这个基于目标的约束设计用来允许你建立交互关系,这些交互关系动态的反应内在的和外在的改变。

2、external changes of occur when the size or shape of your superview changes.

当你的父视图的形状或者尺寸改变,外部的改变就发生了。

3、when your app’s content changes ,the new content may require a different layout than the old.

当你的app的内容改变的时候,新的内容也许需要一个相对老的不同的布局。

4、Auto Layout dynamically calculates the size and position of all the views in your view hierarchy

自动布局动态在你的视图层级计算所有视图的尺寸和位置。

5、a news app needs to adjust its layout based on the size of the individual news articles.

一个新闻app需要使用它的布局适应个体新闻的标题。

参老文章


http://www.jianshu.com/p/b637d3d21606

1、translatesAutoresizingMaskIntoConstraints

translate 转化,翻译

mask 布局

2、autoresizing 早期进行UI布局的技术,仅使用于约束父子控件之间的关系

3、autoLayout 比autoresizing 更高级,旨在替代autoresizing,可以设置任何控件之间的关系。

4、sizeclass用于解决越来越多的屏幕尺寸的适配问题。

5、autoresizing 和auto layout 不能共存,所以如果使用autoresizing ,就不能勾选use auto layout.

6、每在storyboard 中对控件添加一个约束,就代表添加了一个约束对象。

7、leading edges 走边对齐

     trailing edges右边对齐

    top edges 顶部对齐

    bottom edges 底部对齐

8、By default, the autoresizing mask on a view gives rise to constraints that fully determine 

 the view's position. This allows the auto layout system to track the frames of views whose 

 layout is controlled manually (through -setFrame:, for example).

 When you elect to position the view using auto layout by adding your own constraints, 

 you must set this property to NO. IB will do this for you.

gives rise to  产生了

默认情况下,在视图自动布局产生了决定视图位置的约束,这允许自动布局系统去追踪那些通过人为控制的视图的frame,当你选择通过自动布局来设定你自己的位置的时候,你必须将这个属性设置为no,ib将会替你做这个事。

9By default, the property is set totrue for any view you programmatically create. If you add views in Interface Builder, the system automatically sets this property tofalse.

默认情况下,当你书写代码时,这个属性被设置为yes,但当你给ib加视图时,系统会自动设置这个属性为false.

pure layout 

1、在 UITextView+PlaceHolder里面,

为什么只能用[view autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:[self superview] withOffset:-30];

不能用 [view autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:- (2 * DISTANCEY)];

2、友盟分享崩溃,点击那个tap栏,挂掉了。————商量

3、加载图片时,记得不要去加载那些框架里面的,那些图片加载不到。我们去调用iamge@2x.png调用不到。

4、edge top,bottom,left,right 是正数,那么他都在superview的里面

5、That is, if you pin a view to the left edge of its superview, you’re really pinning it to the minimum x-value of the superview’s bounds. Changing the bounds origin of the superview does not change the position of the view.

那是,如果你给一个视图设置了一个边沿的约束,你是真的设置了这个视图对你的父视图的最大的x值,改变父视图的位置不会改变这个视图的位置。

5、The UIScrollView class scrolls its content by changing the origin of its bounds. To make this work with Auto Layout, the top, left, bottom, and right edges within a scroll view now mean the edges of its content view.

滑动视图通过改变它的origin来滑动它的视图,为了让滑动视图适应自动布局,在一个滑动视图的顶、左、底、右边沿意味着这是他的内容视图的边沿。

6、Mixed Approach混合方法

7、Position and size your scroll view with constraints external to the scroll view—that is, the translatesAutoresizingMaskIntoConstraints property is set to NO.

你用约束滑动视图的位置和尺寸与scrollview不相关,换句话说,translatesAutoresizingMaskIntoConstraints属性设置为NO

8Create a plain UIView content view for your scroll view that will be the size you want your content to have. Make it a subview of the scroll view but let it continue to translate the autoresizing mask into constraints

为你的滑动视图创建一个清晰地视图,这个内容视图将会是你的滑动视图需要的尺寸。使它成为你滑动视图的子视图,但是让它继续将 the autoresizing mask转换为约束。

9Create the views you want to put inside the content view and configure their constraints so as to position them within the content view.

创建你想放到内容视图的视图集,配置他们的约束在内容视图的里面。

10、[self.shareLabelautoAlignAxisToSuperviewMarginAxis:ALAxisVertical];设置水平居中