Upgrade to Pro — share decks privately, control downloads, hide ads and more …

使うっきゃない!iOS9で楽になったAuto Layout!

Sato Takeshi
February 20, 2016

使うっきゃない!iOS9で楽になったAuto Layout!

Swiftビギナーズ勉強会 第13回
発表資料です。
iOS9から追加されたStackViewとAnchorsを説明しました
https://swift-beginners.doorkeeper.jp/events/37317

Sato Takeshi

February 20, 2016
Tweet

More Decks by Sato Takeshi

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ ʲ໊લʳ ࠤ౻߶࢜ ʲ͓࢓ࣄʳ લ͸डୗ*5اۀͰΠϯϑϥͷอकӡ༻ۀ຿ ࠓ͸༗ݶձࣾΧΠΧΠͰJ04ΞϓϦ࡞੒ ʲͰ͖Δ͜ͱʳ SVCZ J04 BQBUDI

    MJOVY αʔόʔपΓʣ 5XJMJP 8FCϑϩϯτ ʲϦϦʔεΞϓϦʳ :VNF)PTIJ -JMMZ#MPDLFS޿ࠂϒϩοΫͰαΫαΫշద4BGBSJʹʂ
  2. /4-BZPVU"ODIPSΫϥε௥Ճʂ redView.leadingAnchor.constraintEqualToAnchor(yellowV iew.trailingAnchor,constant: 8).active = true *UFN SFE7JFX "UUSJCVUF MFBEJOH"ODIPS

    3FMBUJPOTIJQ DPOTUSBJOU&RVBM5P"ODIPS .VMUJQMJFS ͳ͠ʢσϑΥϧτ *UFN ZFMMPX7JFX "UUSJCVUF USBJMJOH"ODIPS $POTUBOU  ϓϩύςΟͰ੍໿ΛઃఆͰ͖Δʂ
  3. ࠓ·Ͱͷ"VUP-BZPVU࡞੒ίʔυ w /4-BZPVU$POTUSBJOUΫϥε w "VUP-BZPVUʹඞཁͳཁૉΛҾ਺Ͱઃఆ w Θ͔Γ΍͍͕͢ίʔυྔ͕͓͓͍ w 7JTVBM'PSNBU-BOHVBHF w

    7JTVBM'PSNBU-BOHVBHFͱ͍͏੍໿ઃఆͷه๏Λ࢖ ͍ઃఆ w ෳ਺ͷ੍໿Λ͍͖ͬʹઃఆͰ͖Δ w จࣈྻͰઃఆ͢ΔͷͰෆਖ਼ͳه๏Λॻ͍ͨ࣌ʹ෼͔Δ ͷ͸࣮ߦ࣌ͷΈ w தԝἧ͑ͱ͔ɺϚʔδϯઃఆͷํ๏͕Θ͔Γʹ͍͘
  4. /4-BZPVU$POTUSBJOUΫϥε let redViewLeadingConstraint = NSLayoutConstraint(item: redView, attribute: NSLayoutAttribute.Leading, relatedBy: NSLayoutRelation.Equal,

    toItem: yellowView, attribute: NSLayoutAttribute.Trailing, multiplier: 1.0, constant: 8) self.view.addConstraint(redViewLeadingConstraint)
  5. 7JTVBM'PSNBU-BOHVBHF let views = [ "redView" : redView, "yellowView" :

    yellowView ] let redViewHorizonConstrains = NSLayoutConstraint.constraintsWithVisualFormat(" H:|-[yellowView]-8-[redView]-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views) self.view.addConstraint(redViewHorizonConstrains )
  6. σϞ w ԼͷϨΠΞ΢τΛͭͷॻ͖ํͰΈͯΈ·͢ʂ SFE7JFX ZFMMPX7JFX ਌Ϗϡʔ    

      SFE7JFX ͸਌Ϗϡʔͷ ෯ ͷେ͖͞ SFE7JFXͱ ZFMMPX7JFX ͸ಉ͡ େ͖͞