zoukankan      html  css  js  c++  java
  • iOS 使用代码创建约束,实现自动布局

    ///与下面约束对象属性截图相对应
    //使用Auto Layout约束,禁止将Autoresizing Mask转换为约束 [self.funcView setTranslatesAutoresizingMaskIntoConstraints:NO]; /** *@1.constraintWithItem:你想要约束的视图 *@2.attribute:约束的属性(枚举值,可使用com键查看) *@3.relatedBy:与约束的父视图的关系(枚举值) *@4.toItem:约束对象的父视图 *@5.attribute:约束的属性(枚举值,可使用com键查看),一般情况下与第二个参数写一样的 *@6.multiplier:相对于父视图的约束比例 *@7.constant:约束间隔 */ //与约束视图与父视图宽度一致 NSLayoutConstraint *w = [NSLayoutConstraint constraintWithItem:_funcView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:_fview attribute:NSLayoutAttributeWidth multiplier:1 constant:0]; //与约束视图与父视图高度一致 NSLayoutConstraint *h = [NSLayoutConstraint constraintWithItem:_funcView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:_fview attribute:NSLayoutAttributeHeight multiplier:1 constant:0]; //与约束视图与父视图center.x一致 NSLayoutConstraint *x = [NSLayoutConstraint constraintWithItem:_funcView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:_fview attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; //与约束视图与父视图center.y一致 NSLayoutConstraint *y = [NSLayoutConstraint constraintWithItem:_funcView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_fview attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]; //把约束添加到父视图上 NSArray *array = @[w,h,x,y]; [_fview addConstraints:array];

     

  • 相关阅读:
    16-1-6 kafka的操作
    16-1-5:MapReduce
    MapReduce概述
    MapReduce的代码实现过程分析
    MapReduce
    HDFS2—SequenceFile(小文件的解决方案)
    HDFS2—federation
    hdfs
    缓解爬虫ip被封的概率
    zookeeper集群搭建
  • 原文地址:https://www.cnblogs.com/mapanguan/p/6510284.html
Copyright © 2011-2022 走看看