首页 > iOS 6 auto layout 下VisualFormat 如何表达两个控件的距离上边距的距离相等?

iOS 6 auto layout 下VisualFormat 如何表达两个控件的距离上边距的距离相等?

[contentView addConstraints:
         [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-65-[userNameLabel]-5-[hotLabel]-(-17)-[hotImgView]"
                                                 options:0
                                                 metrics:nil
                                                   views:NSDictionaryOfVariableBindings(userNameLabel,hotLabel,hotImgView)]];

其中hotLabl 与 hotImgView 的距离上边的高度相等,我这种写法感觉还麻烦,不知道有什么方法能表示距离上边距相等和距离左边距相等的VLF 表示方法


这个真的不太熟悉。。但是对于如何简化一个过于麻烦的表达:

  1. 使用扩展:扩展UIView,添加一个方法返回这些数据
  2. 工具方法:弄一个工具类,静态方法,把view对象传进去,然后返回你需要的数据
【热门文章】
【热门文章】