现在的位置: 首页 > 综合 > 正文

自动布局框架介绍

2018年04月19日 ⁄ 综合 ⁄ 共 1453字 ⁄ 字号 评论关闭
文章目录

Thx:

先推荐一个非常厉害的IOS开发博客:唐巧的技术博客 ,博客中的业界良心,很多东西是从他博客里提及的入门的。他精挑细选了一些好的博客的链接,整理成周报形式,对于我这种不善于找资料的人来说,真的是及时雨。

自动布局框架也是看了他的技术合集中关于Masonry 介绍与实用

BEE 框架

入门门槛太高,只用过简单的类似 html 布局,暂不评论

以及UIView autolayout 框架和此框架介绍的相关布局框架

UIView+AutoLayout vs. the rest

原文

An overview of the Auto Layout options available, ordered from the lowest- to highest-level of abstraction.

    Apple NSLayoutConstraint SDK API
        Pros: Raw power
        Cons: Extremely verbose, tedious to write, difficult to read
    Apple Visual Format Language
        Pros: Concise, convenient
        Cons: Doesn't support some use cases, incomplete compile-time checks, must learn syntax, hard to debug
    Apple Interface Builder
        Pros: Visual, simple
        Cons: Difficult for complex layouts, cannot dynamically set constraints at runtime, encourages hardcoded magic numbers, not always WYSIWYG
    UIView+AutoLayout
        Pros: Simple, efficient, built directly on the iOS SDK, minimal third party code
        Cons: Not the most concise or pure expression of layout code
    High-level layout frameworks (Masonry, KeepLayout)
        Pros: Very clean, simple, and convenient
        Cons: Heavy dependency on third party code, cannot mix with SDK APIs, potential compatibility issues with SDK changes, overloaded Objective-C syntax

翻译版

苹果的 NSLayoutContraint SDK api :不好读不好写

苹果界面生成器:方便实用,不支持一些场景,不完整的编译时检查,必须学习语法,难以调试

UIView+Autolayout: 简单便捷,直接在ios 的SDK构建,最小的第三方代码,缺点:代码不够简洁

高级布局框架:如masonrykeeplayout 优点:非常干净,简单方便。 缺点:第三方库依赖,SKD api 变化是,无法及时兼容,重载OC 的语法。

最后选择了Masonry 作为项目的自动布局框架,考虑到需要代码简洁,第三方库依赖并没那么严重,SDK变化也是有人对应维护的,就算无人维护,深入框架看看是怎么实现的,对自己也是提升。

详情可见:

关于Masonry 介绍与实用

抱歉!评论已关闭.