autoresizingMask

本文为大地瓜原创,欢迎知识共享,转载请注明出处。
虽然你不注明出处我也没什么精力和你计较。
作者微信号:christgreenlaw


用于描述:当superview的bounds改变的时候,接收者如何resize自身。
是一个bit mask

当view的边界改变时,view自动根据其subview的autoresizeMask来resize其subview。可以用C的比特OR操作符UIViewAutoresizing中所描述的常量进行结合,声明一份mask值。这样你可以指明view的哪些dimension应该相对于superview进行grow还是shrink。这个值默认是UIViewAutoresizingNone,也就是说这个view不应该被resize。

When more than one option along the same axis is set, the default behavior is to distribute the size difference proportionally among the flexible portions. The larger the flexible portion, relative to the other flexible portions, the more it is likely to grow. For example, suppose this property includes the UIViewAutoresizingFlexibleWidth and UIViewAutoresizingFlexibleRightMargin constants but does not include the UIViewAutoresizingFlexibleLeftMargin constant, thus indicating that the width of the view’s left margin is fixed but that the view’s width and right margin may change. Thus, the view appears anchored to the left side of its superview while both the view width and the gap to the right of the view increase.

If the autoresizing behaviors do not offer the precise layout that you need for your views, you can use a custom container view and override its layoutSubviews method to position your subviews more precisely.

如果autoresizing的行为没能提供你想要的样式,你可以自定义一个container view,重写其layoutSubviews方法来准确地放置你的subview。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ViewsBecause view objects are the main way your applicati...
    梁光飞阅读 634评论 0 0
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,424评论 0 10
  • 痔疮的最佳治疗药物,痔疮是常见的肛肠疾病,发病率极高,居于世界疾病的首位,痔疮在发病的初期没有明显的症状,一旦有症...
    泪痕A阅读 4,197评论 0 0
  • 人的一生总在不断成长。 要经历“看山是山,看水是水——看山不是山,看水不是水——看山还是山,看水还是水”这么几个阶...
    yiyi2011阅读 182评论 0 1
  • 壹。我想写的开始,你也可以跳过不看。 第一次刻意尝试主题阅读的输出,以前看书的我总是东一本西一本,追求快点看...
    林肆意的妄为林阅读 653评论 0 7