Latest 0.0.3
Homepage https://github.com/tao6/TaoAutoLayout
License MIT
Platforms ios 8.0, requires ARC
Authors

(logo)

  • 这是一个swift的轻量级自动布局框架

Contents

    ///  填充子视图
    ///
    ///  - parameter referView: 参考视图
    ///  - parameter insets:    间距
    public func tao_Fill(referView: UIView, insets: UIEdgeInsets = UIEdgeInsetsZero) -> [NSLayoutConstraint] 
    ///  参照参考视图内部对齐
    ///
    ///  - parameter type:      对齐方式
    ///  - Parameter referView: 参考视图
    ///  - Parameter size:      视图大小,如果是 nil 则不设置大小
    ///  - Parameter offset:    偏移量,默认是 CGPoint(x: 0, y: 0)
    ///
    ///  - returns: 约束数组
    public func tao_AlignInner(type type: tao_AlignType, referView: UIView, size: CGSize?, offset: CGPoint = CGPointZero) -> [NSLayoutConstraint]
    ///  参照参考视图垂直对齐
    ///
    ///  - parameter type:      对齐方式
    ///  - parameter referView: 参考视图
    ///  - parameter size:      视图大小,如果是 nil 则不设置大小
    ///  - parameter offset:    偏移量,默认是 CGPoint(x: 0, y: 0)
    ///
    ///  - returns: 约束数组
    public func tao_AlignVertical(type type: tao_AlignType, referView: UIView, size: CGSize?, offset: CGPoint = CGPointZero) -> [NSLayoutConstraint]
    ///  参照参考视图水平对齐
    ///
    ///  - parameter type:      对齐方式
    ///  - parameter referView: 参考视图
    ///  - parameter size:      视图大小,如果是 nil 则不设置大小
    ///  - parameter offset:    偏移量,默认是 CGPoint(x: 0, y: 0)
    ///
    ///  - returns: 约束数组
    public func tao_AlignHorizontal(type type: tao_AlignType, referView: UIView, size: CGSize?, offset: CGPoint = CGPointZero) -> [NSLayoutConstraint]
    ///  在当前视图内部水平平铺控件
    ///
    ///  - parameter views:  子视图数组
    ///  - parameter insets: 间距
    ///
    ///  - returns: 约束数组
    public func tao_HorizontalTile(views: [UIView], insets: UIEdgeInsets) -> [NSLayoutConstraint] 
    ///  在当前视图内部垂直平铺控件
    ///
    ///  - parameter views:  子视图数组
    ///  - parameter insets: 间距
    ///
    ///  - returns: 约束数组
    public func tao_VerticalTile(views: [UIView], insets: UIEdgeInsets) -> [NSLayoutConstraint]
    ///  从约束数组中查找指定 attribute 的约束
    ///
    ///  - parameter constraintsList: 约束数组
    ///  - parameter attribute:       约束属性
    ///
    ///  - returns: attribute 对应的约束
    public func tao_Constraint(constraintsList: [NSLayoutConstraint], attribute: NSLayoutAttribute) -> NSLayoutConstraint?

Reference

* 展示例子

TaoAutoLayout

tao_AlignInner

    eBtn.tao_AlignInner(type: tao_AlignType.CenterCenter, referView: self, size: CGSizeMake(250, 250))

TaoAutoLayout

tao_AlignVertical

    tlBtn.tao_AlignVertical(type: tao_AlignType.TopLeft, referView: centerBtn, size: smallSize, offset: CGPointMake(0, -10))

TaoAutoLayout

tao_AlignHorizontal

    eBtn.tao_AlignHorizontal(type: tao_AlignType.CenterCenter, referView: self, size: CGSizeMake(250, 250))

TaoAutoLayout

tao_HorizontalTile

    tao_HorizontalTile([lBtn, cBtn, rBtn], insets: UIEdgeInsets.init(top: 74, left: 10, bottom: 10, right: 10))

TaoAutoLayout

tao_VerticalTile

    tao_VerticalTile([tBtn, cBtn, bBtn], insets: UIEdgeInsets.init(top: 74, left: 10, bottom: 10, right: 10))

TaoAutoLayout

tao_Constraint

    let cons = btn!.tao_AlignInner(type: tao_AlignType.CenterCenter, referView: self, size: CGSizeMake(100, 100))
    btnWidth = btn!.tao_Constraint(cons, attribute: NSLayoutAttribute.Width)
    btnHeight = btn!.tao_Constraint(cons, attribute: NSLayoutAttribute.Height)

TaoAutoLayout

Installation with CocoaPods

CocoaPods is a dependency manager for Swift, which automates and simplifies the process of using 3rd-party libraries in your projects. See the Get Started section for more details.

Podfile

platform :ios, '8.0'
use_frameworks!
pod 'TaoAutoLayout', '~>0.0.3'

Licenses

All source code is licensed under the MIT License.

Latest podspec

{
    "name": "TaoAutoLayout",
    "version": "0.0.3",
    "summary": "This is a layout framework for swift.",
    "homepage": "https://github.com/tao6/TaoAutoLayout",
    "license": "MIT",
    "authors": {
        "tao6": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/tao6/TaoAutoLayout.git",
        "tag": "0.0.3"
    },
    "source_files": "TaoAutoLayout/**/*.{swift}",
    "requires_arc": true
}

Pin It on Pinterest

Share This