Skip to content

shaozg/BBLayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BBLayout

介绍:

本框架能同时布局多个view,只需将要布局的试图放到layout里,设置对齐方式以及间距即可完成布局。

BB缩写含义

期望写布局就像玩积木(Building Blocks)一样简单便捷有乐趣。所以,BBLayout又叫积木布局。

Usage

Using CocoaPods

  1. Add the pod BBLayout to your Podfile.

    pod 'BBLayout'
  2. 运行pod install.

  3. 导入头文件

    #import "BBLayoutView.h"

Sample Code (Objective-C)

  1. 定义对象或者属性

    BBLayoutView *layoutView = nil;
  2. 创建layoutView

    CGRect rc = CGRectMake(0, naviBarHeight(), SCREEN_WIDTH, 50);
    _layoutView = [BBLayoutView layoutWithFrame:rc horizontalAlignment:BBLayoutHorizontalAlignmentCenter];
    
  3. 添加要布局的view

    [_layoutView addView:v1 leading:10];
    [_layoutView addView:v2] leading:20];
    [_layoutView addView:v3] leading:30];
    [_layoutView addView:v4] leading:5];
  4. 加到父view上

    [self.view addSubview:_layoutView];

Demo效果(代码中都有的)

图片无法打开?

其它

优势:

  • 布局依赖低,view之间不会明确依赖关系
  • 支持多行模式布局
  • 支持6种水平布局和5种垂直对齐方式