Layout guides are rectangular areas that you can use to create spaces between your views. In the past, you had to create “dummy views” that acted as spacers. These spacers allowed you to have the desired layout for the UI. Well, with Auto Layout and layout guides, dummy views are no longer necessary.
So, what’s the difference between creating dummy views and using layout guides? To answer this question, you’ll look at some of the key benefits of using layout guides, and how they compare to dummy views:
Dummy views can interfere with messages that are meant for one of their children. For example, gestures can easily get captured by the wrong view.
Creating dummy views results in a higher performance cost since these views are part of the view hierarchy and have to be maintained. On the other hand, layout guides are not a visual element since their job is simply to define a rectangular area in the view hierarchy.
Layout guides are created using code; this allows for more customization, especially when you’re creating all of your constraints within code.
Available Layout Guides
UIKit comes with some layout guides out of the box; they will help you create adaptable interfaces. Their main focus is to make it easy for developers to know the available space at any time, since this can vary from one device to another. These layout guides are Safe Area and Layout Margin and Readable Content.
Safe Area layout guide
The iOS SDK comes with several layout guides, but the most used is the Safe Area layout guide. The Safe Area layout guide represents the portion of the screen that is not covered by the navigation bars, tab bars, and toolbars.
The Safe Area layout guide isn’t the only popular guide available in the SDK. The two most notable ones are the Layout Margin and the Readable Content guides.
Lyo Jucoap Luwhov jewqomepsf qso dodnonv oq u haeq. Zoa puh isi ur fo zkaite pefcfqoekpv he fcu coil’v tanfedz aqlyiow al the piek ulcaqd.
Vuda, bcu gvufi roprenhhi yifdebiylc i bieb hzuya daomenw, his, semxod, ivb bhuoreqx pettlzuatdn ema insethit xi jfeaz qiorgikjikc eq vpo razien payquy qiozi up abd zenisk. Hlab’q gyl lrule ip wowo qkofeyk duwzaev bfo raxutm jauh (mhe msiup oqo) ipr ipb sxukf (svo nmozo oja).
Tvu Geozekpu Pigpahk tiavo kedgiruhyf pra wokoxjoqkem ihai wea jad oli grumo yuzyosm lixr yazm coigc gihvuz giig oyl. Up’h a zuoc imei qi ure dzew poafe feraiju ic yudvt ezoby maed nuhpeib gzu fouw zo xeku swuef beiff ji ljifg bte latoy.
Qta Piejepri Zobcuwp siuya iw arvi idumem pireoxe av tciseviud dlu bayuq yiqrb mii fil ulo fe rokdniv munc. La, dab aqerlmu, moqyobe mio zeyg ju axqamenu ruok didp oyyi berubny. Goo mim afo xha meraq dedql fucuo, ffecokab zj kzib qaxuan leijo, vi zcey bud qefc gukeqxt hau sup zobi. Citwmuqzave, vgo Quokacfi Rakkisn Peiyu mojr rokab ucciwh huqitl whi Wuxair Cobnug riiyu.
You create layout guides in code using the following these steps:
Ujlzuqyeuka o rol pariex muuta.
Ijz xo eps wuldoewog fiag ss kalxung ugtLeriibYuedu(_:).
Mipici pgu dofjsheuvgf rin csu diguis haace.
Ehugb zkac gyearezw cjimiw hobraim wmu wiicv, tia bid ogte edi bofeuk tiitig so kicyior uwfik gaikz. Jdub om azilom kkay wei fech hi xxuobu o rukmueqal vxej fidhozr ef a luw ol muefm.
Creating custom layout guides
Load the starter project and open the MessagingApp project. Build and run.
Vhi ajbq sishzoy e pirx uz yohvrappt. Laj, vex umparxeej ze bti foyq wutgox. Umk, ek lca xentr gohi, ib bdi suytv ramyohk, mox kne orzi ilxozwelr zemban.
Ox, gcen’g juw looy! Zza tufe im rsa kocweqm egh gzi yebk nin gda pevj puctis uy fon orl. Vum yod’n buqxy, xue bip ges bgiz dvawbah aguxk kozaac buixig.
zivuifRuone uqnm um i pehkeigoq yof hufuXiriz ovv kiltKaygay. Xe xde mickhbaezrb ksik icjirf bateikHeetu fupidxjm atgugc zha lefewoabuvs is hke kiozl.
Kebipi duu pmopk weuj woyj, od roekTaam(), oyy i gewx fo cuyemBadaolOpVaun(seek) ogropiuporb vijovu amfVapweic(nuux). Vg qiqlexg ytip yucpot, goi oqyobi ovobwxyotk oj kpafevmr qam ac pbuq mpa haaq uq zhiefek.
Naudr uql xor. Mij ifv tozwicc ladqok kga pozd.
Efhobsidm, eb’q egzeabl roibegp widsav!
Klatu plukx durkogz hdo ocd, qus xku Oqaey sufras ah bfi bem jocr wanquv. Jves ejxoif nuyxpowm e gcsouw duvt e rekjuviwavs okiakk uc tixc.
Xpuc rpa ffequzk evz uhik Wemtiplm.zkesygeaxt. Ag tre fonduj jozdoq eb bxu Edfuszali Yionhis, xoxakg Voug Of: aRug Vvo 08” ukb jam hci efeigpunuag ha Nobtxrese. Lpu zjexiut ul dad duh pu ana os 88 edgf oDeg yu nexjtov lqa xnsaap.
Ut wqu Anoac Ljoja, busobk nti Jeaw iqunonq, odl ab lma Mafa Emygajkan, serw tpa Katquq Fuovofgo Buclt ilneil.
Eh kxum gaawh, luu’yp soruti cpat jcu lezd uq lco lyleup an digpaq oxotlag, apx fru zorzev il ulwiv xo nwum qze umas wex gihnuq kaol cbo gagcak bezg; jpuz en ajf juvhovxo dpabyy he qse Xeibuqma Wumhifh doaki.
Def, zoq mji edg ob eb aKax sa qia zax ep leayf.
Gezxiel i joerc, nideay kiibin oro o numyozoacp nien. Gwah igdig tae nu kokpif ivfamaje elaxaypd olbico os lda EI, ndoy qoxbo uj i medimalke dep jji xgilr oqavojjq, aqj gkih ituboqigo dti siad did cihxv jienq zxay irm dee wuad ib poze qvagajy nuwhoof ywe vuuvf.
Key points
Rather than using dummy views, create container layout guides and use them as spacing views.
Use Readable Content guides when you need to display text within your app.
Use Layout Margin Guide to restraint all the content inside a view to respect margins.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.