V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
colatin
V2EX  ›  iDev

iOS 蛋疼的布局,怒了!为啥没有 LinearLayout?

  •  
  •   colatin · Mar 30, 2016 · 6419 views
    This topic created in 3680 days ago, the information mentioned may be changed or developed.

    作为一个 Android 开发者,有幸接触了一下 iOS 开发,对 iOS 开发者在布局方面表示深深的同情。于是做了个小控件分享一下。奉行 frame layout 和有幸在 iOS9+公司的朋友也不要躲。 链接 https://github.com/qianbin/AutoLinearLayoutView

    screenshot

    Supplement 1  ·  Apr 6, 2016

    附加两张截图

    ---

    22 replies    2016-04-06 22:37:32 +08:00
    franklinyu
        1
    franklinyu  
       Mar 31, 2016
    空格和 tab 混排?
    ichanne
        2
    ichanne  
       Mar 31, 2016 via iPhone
    UIStackView 自带,谢谢
    mofet
        3
    mofet  
       Mar 31, 2016
    iOS 一般不用这种表格和比例为依据的 Layout ,屏幕 ppi 都一样,界面元素多使用固定尺寸、相对坐标。
    另有 UIStackView
    ichanne
        4
    ichanne  
       Mar 31, 2016
    看了下楼主的源码,写的很好,我要学习一个, AutoLayout 用得很 6
    wohenyingyu01
        5
    wohenyingyu01  
       Mar 31, 2016
    uistackview +1
    wohenyingyu01
        6
    wohenyingyu01  
       Mar 31, 2016
    @wohenyingyu01 看了源码,好 6 的样子,可否上 cocoapods ?
    ggyb11
        7
    ggyb11  
       Mar 31, 2016
    典型的 Android 思维
    tigerZhang
        8
    tigerZhang  
       Mar 31, 2016
    nicevar
        9
    nicevar  
       Mar 31, 2016
    哈哈,不错,支持一下楼主
    典型的平台迁移综合症
    mornlight
        10
    mornlight  
       Mar 31, 2016
    用 Masonry 之后早已把原生的 AutoLayout 写法忘了...
    superleexpert
        11
    superleexpert  
       Mar 31, 2016
    stackView 还得等下过度, Masonry 目前遇到的需求都能支持。
    colatin
        12
    colatin  
    OP
       Mar 31, 2016
    @ichanne ios9+有没有?信不信比 stack view 好用?
    colatin
        13
    colatin  
    OP
       Mar 31, 2016
    @wohenyingyu01 准备上
    colatin
        14
    colatin  
    OP
       Mar 31, 2016
    这个是黑魔法。
    个人认为 stackview 本身太挫,不够干净
    colatin
        15
    colatin  
    OP
       Mar 31, 2016
    @ggyb11 好的东西就得互相借鉴。 android 的 relative layout 如果能像 auto layout 那样跨层级约束就好了
    colatin
        16
    colatin  
    OP
       Mar 31, 2016
    @mofet 那苹果吃饱了撑了加了 stack view ?
    mofet
        17
    mofet  
       Mar 31, 2016
    @colatin 屌哦
    Rubbly
        18
    Rubbly  
       Mar 31, 2016   ❤️ 1
    说起布局 还是喜欢 xaml 的这一套
    HelveticaNeue
        19
    HelveticaNeue  
       Apr 5, 2016
    @colatin 能否简单介绍一下不干净的地方?
    我比较过 UIStackView 和 OAStackView 的布局速度, UIStackView 大概是 OAStackView 速度的 100 多倍,十分吓人,但是我没有研究过 UIStackView 的实现。所以能否简单说一下不干净的地方?
    colatin
        20
    colatin  
    OP
       Apr 5, 2016
    @wuyuehyang
    先说一下比较挫的地方,有时候 update frame 无法 misplacement 的黄框
    不干净指的是有些属性不应该由 stackview 提供,比如 distribution 属性
    pheyer
        21
    pheyer  
       Apr 5, 2016
    @wuyuehyang 我有一部分布局用了 OAStackView ,看了你这个觉得以后没必要用了
    colatin
        22
    colatin  
    OP
       Apr 6, 2016   ❤️ 1
    @wohenyingyu01 已经弄到 cocoa pods 上了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3589 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 11:01 · PVG 19:01 · LAX 04:01 · JFK 07:01
    ♥ Do have faith in what you're doing.