要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
auto-Auto Layout 工具旨在移除编写 Auto Layout 繁琐语法的劳动。适用于 MVP 和 Splash/Homepages,autoAutoLayout 允许开发者根据任何屏幕大小—通过 Xib/Nibs、Storyboards/Interface Builder 或编程方式设计视图。AutoAutoLayout 遍历所有子视图 UIVIew 对象,使用 NSLayoutConstraint,并根据用户的屏幕重新定位这些对象。
首先,必须删除约束
[self.view removeConstraints:self.view.constraints];
要自动-Auto Layout 所有 UIView 子视图对象
[AutoAutoLayout autoAutoLayoutFromBaseModel:@"5" forSubviewsOf:self.view];
//In this case, developer laid out his objects based on an (example) iPhone 5-sized screen. Replace this NSString with any other model.
-或者- 相比于迭代 self.view 中的所有子视图对象,可以选定特定的对象数组进行自动-Auto Layout
NSArray *exampleArray = @[self.titleLabel, self.mainButton];
[AutoAutoLayout autoAutoLayoutFromArrayOfSubviews:exampleArray fromBaseModel:@"5" forSubviewsOf:self.view];
autoAutoLayout 目前不支持横竖屏幕方向。
autoAutoLayout 目前不会缩小或放大字体大小。然而,在大多数应用的 UI 中已经表明,虽然图像和视图随着更大手机的屏幕而扩大,但字体大小(以及稍微小一点的栏高)并不会以同样的比例扩大。”未来的开发将提供方法,让开发者可以通过比例调整对象(如 UILabel)的字体大小。
最后,虽然 autoAutoLayout 扩大/缩小 TableView 和 CollectionView 对象的框架,但是请注意,autoAutolayout 只缩放 TableView 和 Collection View 本身的框架,并不包括其底下的单元格。未来的开发将尝试相应地调整 Table/Collection Cells 的大小,或者在失败的情况下调整方法以忽略 UIView 中的 TableView 和 CollectionView 对象。
iOS 7.0+
Cathy Chen,[email protected]
autoAutoLayout 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。