-(void)makeEqualDisViews:(NSArray *)views inView:(UIView *)containerView LRpadding:(CGFloat)LRpadding viewWidth:(CGFloat)viewWidth

{

UIView * lastView;

__block NSInteger index = 0;

NSMutableArray * tempViewsArray = [NSMutableArray new];

for( int i = 0; i < views.count-1; ++ i )

{

UIView * v = [UIView new];

v.backgroundColor = [UIColor blueColor];

[containerView addSubview:v];

[tempViewsArray addObject:v];

[v mas_makeConstraints:^(MASConstraintMaker *make) {

make.height.equalTo(@5);

make.bottom.equalTo(containerView.mas_bottom);

}];

if( i > 0 )

{

[v mas_makeConstraints:^(MASConstraintMaker *make) {

make.width.equalTo(((UIView*)[tempViewsArray objectAtIndex:0]).mas_width);

}];

}

}

for( UIView * view in views )

{

if( index >= 10 )

break;

[containerView addSubview:view];

if( lastView )

{

[view mas_makeConstraints:^(MASConstraintMaker *make) {

UIView * v = tempViewsArray[index];

make.left.equalTo(v.mas_right);

make.width.height.equalTo([NSNumber numberWithFloat:viewWidth]);

make.centerY.equalTo(containerView);

if( index < views.count-2)

{

UIView * rV = tempViewsArray[index+1];

make.right.equalTo(rV.mas_left);

}

++ index;

}];

}

else

{

[view mas_makeConstraints:^(MASConstraintMaker *make) {

make.width.height.equalTo([NSNumber numberWithFloat:viewWidth]);

make.left.equalTo(containerView).offset(LRpadding);

make.centerY.equalTo(containerView);

}];

UIView * v = tempViewsArray[0];

[v mas_makeConstraints:^(MASConstraintMaker *make) {

make.left.equalTo(view.mas_right);

}];

}

lastView = view;

}

if( lastView )

{

[lastView mas_makeConstraints:^(MASConstraintMaker *make) {

make.right.equalTo(containerView).offset(-LRpadding);

}];

}

}

主要是加入了辅助的价格view来进行排列

Masonry 固定宽度 等间距的更多相关文章

  1. Masonry的一些等间距布局

    控件之间的间距相等,但是控件的宽度是不定的. 下列的代码:定义间距为10,yellowview的宽度是由redView的宽度计算出来的. UIView *redView = [[UIView allo ...

  2. masonry框架的使用之-多个视图的均匀等间距分布

    __weak typeof(self) weakSelf = self; //对self进行weak化,否则造成循环引用无法释放controller UIView * tempView = [[UIV ...

  3. Masonry和FDTemplateLayoutCell 结合使用示例Demo

    我们知道,界面布局可以用Storyboard或Xib结合Autolayout实现,如果用纯代码布局,比较热门的有Masonry.SDAutoLayout,下面的简单demo,采用纯代码布局,实现不定高 ...

  4. 【原】iOS学习之Masonry第三方约束

    1.Masonry概述 目前最流行的Autolayout第三方框架 用优雅的代码方式编写Autolayout 省去了苹果官方恶心的Autolayout代码 大大提高了开发效率 框架地址:https:/ ...

  5. iOS AutoLayout自动布局&Masonry介绍与使用实践

    Masonry介绍与使用实践:快速上手Autolayout http://www.cnblogs.com/xiaofeixiang/p/5127825.html http://www.cocoachi ...

  6. 流式布局&固定宽度&响应式&rem

    我们现在在切页面布局的使用常用的单位是px,这是一个绝对单位,web app的屏幕适配有很多中做法,例如:流式布局.限死宽度,还有就是通过响应式来做,但是这些方案都不是最佳的解决方法. 1.流式布局: ...

  7. iOS开发 Masonry的简单使用

    首先,在正式使用Masonry之前,我们先来看看在xib中我们是如何使用AutoLayout     从图中我们可以看出,只要设置相应得局限,控制好父视图与子视图之间的关系就应该很ok的拖出你需要的需 ...

  8. PureLayout和Masonry比较

    一年前那时我做iOS开发,为了自动布局适配多种屏幕,我一般使用Masonry,后来偶然地在一个视频教程中发现老师使用了UIView+Autolayout(现在作者改名为PureLayout)自动布局, ...

  9. iOS-布局-Masonry

    一.说明:demo中的举例视图介绍  UIView        *_blackView;     作为父视图  UIView        *_redView;       与父视图内边距为10   ...

随机推荐

  1. 278. First Bad Version

    题目: You are a product manager and currently leading a team to develop a new product. Unfortunately, ...

  2. 转载 a href=#与 a href=javascript:void(0) 的区别

    a href="#"> 点击链接后,页面会向上滚到页首,# 默认锚点为 #TOP <a href="javascript:void(0)" onCl ...

  3. USACO Section 4.2: Drainage Ditches

    最大流的模板题 /* ID: yingzho1 LANG: C++ TASK: ditch */ #include <iostream> #include <fstream> ...

  4. php克隆 自动加载

    PHP加载 include() 函数 include() 函数可获得指定文件中的所有文本,并把文本拷贝到使用 include 函数的文件中. 例子 1 假设您拥有一个标准的页眉文件,名为 " ...

  5. 监听Activity进入后台(最小化),并根据时间判断是否超时,此解决办法可用于超时重登陆

    通过重写一个继承自Activity的基类中的onUserLeaveHint()方法,当用户按Home键等操作使程序进入后台时即开始计时,当用户使程序恢复为前台显示时执行onResume()方法,在其中 ...

  6. C# 获取所有打印机

    List<string> print = Cprinter.GetLocalPrinter(); /// <summary> /// 获取所有打印机 /// </summ ...

  7. 关于RotateAnimation的各构造方法的参数

    本文以RotateAnimation的构造方法 讲解. RotateAnimation(float fromDegrees, float toDegrees) 其他构造器的旋转也可参考这副图. Rot ...

  8. 手机号段、ip地址归属地大全,最新手机号段归属地,IP地址归属地数据库

    百事通:http://www.114best.com/dh/114.aspx?w=17097232323,联通识别为电信的,1349错 二三四五:http://tools.2345.com/frame ...

  9. android 开发如何做内存优化

    不少人认为JAVA程序,因为有垃圾回收机制,应该没有内存泄露.其实如果我 们一个程序中,已经不再使用某个对象,但是因为仍然有引用指向它,垃圾回收器就无法回收它,当然该对象占用的内存就无法被使用,这就造 ...

  10. C#分页类

    using System.Linq; using System.Collections.Generic; namespace CommonLibrary { public class PagedLis ...