UIView-AutoLayoutView 1.0.2

UIView-AutoLayoutView 1.0.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2015年4月

Arthur Ariel Sabintsev 维护。



  • Arthur Ariel Sabintsev

UIView+AutoLayoutView

关于

这是在 UIView 上的一个小 Objective-C 分类,它创建一个可编程 AutoLayout 的 UIView 对象。这个类对于经常在 xibs 和 storyboards 外面进行 AutoLayout 定义的人来说很有用。

更新日志 (v1.0.2)

  • 明确导入 UIKit
  • 为 README 添加了 Swift 文档

安装说明

手动操作

只需将 UIView+AutoLayoutView 文件夹拖入您的项目中,并在需要访问其提供的信息的类中引用 UIView+AutoLayoutView.h 即可。

接口

@interface UIView (AutoLayoutView)

+ (instancetype)newAutoLayoutView;
+ (void)updateLayoutForView:(UIView *)view;

@end

实现

+ (instancetype)newAutoLayoutView
{
    UIView *view = [self new];
    [view setTranslatesAutoresizingMaskIntoConstraints:NO];

    return view;
}

+ (void)updateLayoutForView:(UIView *)view
{
    [view setNeedsLayout];
    [view layoutIfNeeded];
}

@end

用法

Objective-C

// Create an AutoLaoyut view
MyView *myView = [MyView autoLayoutNew]; // Creates a new progrmmatic-AutoLayout ready object

// Update the view after the constraints are set
[UIView updateLayoutForView:myView];

Swift

// Create an AutoLaoyut view
let myView = MyView.autoLayoutNew() // Creates a new progrmmatic-AutoLayout ready object

// Update the view after the constraints are set
UIView.updateLayoutForView(myView);

创建者及维护者

Arthur Ariel Sabintsev