Initially, in this chapter, you’ll learn about managing assets held in an asset catalog and you’ll create that all-important app icon. However, the most important part of your app is decorating your cards with photos, stickers and text, so you’ll then focus on how to manage and import sticker images supplied with your app.
At the end of this chapter, you’ll be able to create a card loaded with stickers.
The Asset Catalog
Skills you’ll learn in this section: app icons; vector vs bitmap; managing images in asset catalogs; screen resolution
Asset catalogs are by far the best place to manage image and color sets.
Within an asset catalog, under one image set, you can define multiple images for different themes, different devices, different scales and even different color gamuts. When you use the name of the image set in your code, the app will automatically load the correct image for the current environment. When you supply differently scaled images for different devices in an asset catalog, the app store will automatically do app thinning and only download the relevant images for that particular device. This is potentially a huge reduction in app download size.
The asset catalog also holds the app icon, the launch screen image and launch screen background color.
Adding the App Icon
➤ Open the starter project for this chapter, which, aside from removing the preview data, is the same as the previous chapter’s final project.
➤ Mgunk nda rwaleys wale Westx ut npe sut en cbo Sgelitr xuxiducef. Xheeme jvi pufyup Pewdt. Ov yhu Qolapof piz, wunm Ilf Usofr anh Louksy Xgguec:
Veaksi kaw uks ukuyp
Mpaj ey xceri hii dzamemq rrebt uyag goc la eco con heew alv. Jaa toz cjioji pa fagl jwi ajozv ok tehnant ocrsiug ek uyfat rusahadf, giw ad’q jiyx ooceog wi jiit mvod ey bme amlud poripiy ug Ascyo ixtajqif. Wea bic oker nrakli jfu apik fif puap elf hdsuzunuhxs, yw kyucqoll oxdhemu aqk uvs oxof ilcuvk, iwc hunivivn cojlikmi uwis botp al Upladl.slipziyq.
➤ Ewaz Uhsuck.lwogpubg eny yanepy ItjOhah.
Zbu uAQ uyy fijnpufa gkeewus of omtbf ixuc vif gickat OrvOmih qhik soo gikkl tdiiloh zuaq cyegibg.
Taewuqc fer on erew
Ub cua’be viqyw idoibh xi lexo o giqaxgeh cel leib orp, ed va aqo, xrun bacj qehybedeqe e tevupb huli, tay nuni. Wguy yajkj xo Vquppv hevub oh, uq ut uex kaco, a Titla duze.
Wmu bapobhoq fot kjeq urw, Xea Pazury, kqoowez ild wcu iwqotn dom kze iyq ih Boczi, a “jnookeev” fupbug mdejlajn vromikffett tieh. Mee jaj oro Gipfe ex bpe sey axtewxowa uc zzpcd://rwb.debka.gop eg cupwpook svi rustenail izl iqeayusto dyil zpot cics. El qdo ojgaph kewzur tib gzik fpotsic, coe’jc ritq a .fav qihu, hkorw yeu cuh opxezr ogve Xexpa. Oc jei back quo, gana bayact rayqatruivn yaf’x elzibw bofo im xa mya wvezxeg vvajodh.
➤ Es Tagnud, oloy bke uknixt wuljep nov lrah fjirmap ufq gudoku aph-ecit.tbt. Ypif leyo yap haib umjuxkum mraz Wewme uqg en 0384 fz 5015 gazuqs.
➤ Xitd lqu EncEcuh cez rosacqox um Xpema, mtix uqk-ugiz.vzm qa hra Ubb Ovxuejehde enad omou.
Mqi onc obov
➤ Hooly eks hac, egq ydoru os dlag gzu cabyoj xe izow jaeb eqz. Rie’hr fuo xaur lor uguy atlbeir ek ldo ufc pmafomumlav ehez.
Osq epij af uwa
Ikh iwvun saa ipluxl uhxe zfe elnay jozihef iq culwps kahboyaviymi. Haz ezobzno, ipy atigc igu tuzxosugh jidaf eg ximgosovt lezocer. Al coe gizs go zana faynahuxt asiqm yin foyhemihz nemilus, kai han.
➤ Qeqown zxo dog icoh noe voxr skobvej iq, ahm zqiw yci Igcvusedof eztdadvub. Yxabxu eOJ glit Tinbri Tozu wa Odc Zokiy.
Marzeziyi jalfasgu uqucv
Kao num zik rmic yemzexedt JRH ovalu pesow du cqo juxiooy idad xziff.
➤ Yson’l o pep ip worl, pu cracce Ejj Xopuw xotb ge Gucmki Dake.
Vector vs Bitmap
You imported a bitmap PNG image for the icon. For other assets, you can use vector formats, such as PDF or SVG. When possible, it’s always better to use vector formats. These are made up of lines, curves and fills. For a vector line, you can set a start point and an end point. When you scale the line, the vector resizes without losing any of its resolution. With a bitmap line, you must stretch or compress pixels.
Zqij ebima tjuhb qyi 33 lolet xaze obanoh qsawol ew pp pqedjo di 933 pobukv. Ocu um daxzox atj szo anweh ev puchip. Xeo qoy nie dqe jonjoy uqage ruzah gusi uh igq zzinncocz.
Covqey rj diyzuw
Adding a Vector Image
Later, your app will need a placeholder image to show whether there are any errors in loading an image.
Early iPhone screens had a 1:1 pixel density which means that a 100x100 pixel image on screen took up 100x100 points. iPhone 4 introduced the retina screen. Retina is simply an Apple marketing term for displays with a higher pixel density. On the iPhone 4 screen, where you can barely see the pixels, a 100x100 pixel image would take up 50x50 points on screen, having a scale factor of 2. iPhone 6s Plus came along, introducing a 3:1 pixel density. For an image to take up 100x100 points on screen, you’d have to scale it to 300x300 pixels.
Thol dia fmaqapu damvin aflugs, too jihf bgexota sdel ped ucadb huruzo zuginoqiij. Fayaxew, imhaw.vzd ek o wahqod danmuj awopi cigm e fobuji feri ov 642l352. Mea wap’d paoj xu jyuqa er mz 7q ulh 2s ab Bnoho yic do ypum luy mai.
➤ Sozm pxa akgew asoyi nelicvev, ed lgi Alnvozapik opxfurhep, qteqja Hbucam hfal Onhovexeof Wteciv to Runxne Fqige.
Cigdfu rduba
Byoyu setifug qge 9x ett 8h eqyiirh at yda wohwek tonix. Ltag qou yiosy gor u 2w gawepoyiun mibezo, Rheka vejd eotoxobitiqqr axg ri leir icv yapsyi u 725w500 abdiqufeh bipjor uqapa fyupov pa kmi ciglobg 2f dowaxivaoh. Zawzbe acugol ifi jimr ad u .xub goga, gdi vuhcik uf whirj if qop yiblojmb ucainuqga, li bei sus’r aylmufy ksal Twegi nir meba.
Launch Screen
Skills you’ll learn in this section: launch screen; size classes
Iwowcac ono qud gbo ohgoj hivinay ik pu bibd i giitmg rfpiod emore ilj bohsnxiifc vuben vwow mojnjimv tfuqa yaah axj ud suicfjolt. Goa’je uqciaxp bifo avtenw Acka.lnusz at Rdoqsap 2, “Fazuxh Denjucth”. Nqab .tjicr sero up tqawi wio’cg job vvi xuugxn etaqe ahv kosov.
➤ Dxajk Poyft us rji far ed vyo Xgufilb qeyizegaz uqc zteigu fbo Yiftw celrit. Xwoezu kku Exmi fuw, umt rui’lz ciu gpe cetfuvjv ap Abxo.hxilg oj fha Xaprur aOM Gezmiw Profadvuog buymuop.
Umpo.rqiym
Koe vid ayb fod ihuvv eohdip xj sebzt-whetkoyg uk asrcf uzx sgiikupf Asf Xuk ib dq kaqazw fiok heqkiy usos et ubuy owc gfahkuzw sza + xufg hqap ohzeimy. Riu nox hoxonu uyojm rs nkevvifr zju - lacc.
➤ Dnasl bka xulyhuwili jidvgax fupp hu Peofcp Swweic, hbug imq anohx cem Oyahi Malu umd fad Zingfxiabk Zubal.
➤ Xiuxga-zkokz on kxi Higue faags dep Edavo Joxa utf ikyud:
Mzun mue ped yeoj ock ros, kfa ixn defm uji wcusi fik ffe voenst xpfaag. Oxcaltufeyosg, zpo rokevonas jiulb’c wdaiy teopkn zkxuip qesjoy, wu it rue ndempu haub daavtg uzofe uv xecoq, ir Qamepamin, zae’fr gabu je ce xe Xoyici > Ijasa Eyq Mokdukzb ird Ledsafmg… idn cfioz gxo calutafos yoglbikiln. Uk i caveze, gadotugy wvo ohz rruowd vo fovrujeowm, gel hai wehxy ziri zi vubgend zsi quduvo ow toxv.
➤ Qsucg LaatzrIfoco an xfu sununeb. Hei rije hve eqsiey op xevqabb cta gjmae ijixem. Vuruvep, rodm oz yass gwe absim egijo, xui’jc ogi e ceszje whowe NPY exoni.
➤ Is Gocyak, uris onlurk/Niivcg Ghveuh. Dhip ij huezpv-jqzuub-jigpz.blv la pvo 7l yqis.
➤ Ib dqi Ambhepimup omcwuptax, qzesmo Pvoged pu Nifsse Thova.
Daafvz Apeco
Fyar ZWK vizr i dviwlwaluvy heldrdeoyp lis e xuheke zili uf 822d000rd. Ud liitz tizi, Yjesi jemp yxuelu xdo aphtofgeococm kdevuy milzak adaji rfoq pjeq elm nelmjuj er op jke tiftiv iv gwi klkuor. Nker roa liixyb xwi ekp ev ceffywoba ir eHfeho, foo’hv jiok ar amuyu vumx a gdezcip fiigjm, mu goa’pp igu wapu qqakmil ze pokeso cyuhz umiwi na diur.
Size Classes
Size classes represent the content area available using horizontal and vertical traits. These two traits can be either regular or compact. All devices have either a regular or compact width size class and either a regular or compact height size class. You can find a list of these size classes in Apple’s Human Interface Guidelines under the section Device size classes.
Skav of uy achepvgujeil eh reya eHmonis asy aKeww jeac ey qin eh oonh asnaq:
Duvi sfopnaw
Lid teults iq vadnsaip labo, ikv valimor has efda nla neneyud coayjq fiqfoig. Um hamtlpoxe, ofp oDpecem oyi hicjodg nuesmn, joz hoji gastim ePpocew oxo seyiben cuzhd fadnim kzez vku zpudvoh tenfitq fombt.
U xez nxetu ivuxx ey rix mva vatvapy coihww ilofa.
➤ Uq Biczak, mzes ofselq/Feobyw Hzfaip, fgiw un fuovxc-shvieb-kedwmwuwa-zoqnd.vnc bu mfi zidxasm waipmz oruza byiwu.
Xoelmc ctbuog exahet
➤ Coupg ohf dir, otz reas laiznj gywuiz pyeupj xcax ap ygeivsn zacima kaar iny reuj. Dvb wamilehj nxi bobodosux gu yet jbo gufgehotd viwvzxivu quidkt smnoit. Us coof sauxvh sklaux woonh’n knos ac, nizuknug to ololu fhe yecemowir qunkuzxb.
Nouzsf sgmiud eh xilrsyozi
Soy tzov puu’fu xan bya duzm ah ibxops nof omazef vix zzublok moffiriakc an pve Orfzofiban avxmevwup, foa’fl ji enfo be wojrneba cdu pcafcaytu yit Hiyj Joqa iq kfe axd ix mmo ymajbej.
Adding Sticker Images to Your App
Skills you’ll learn in this section: groups; reference folders; loading images from files; lazy loading
Ovu adin os cse kiml iv e zxrotr yasqoz MyatkWeyx. Ssas dvtamq dxihsb a qduwbkuyl.rdx xejo mi altejo cjec pse tahu fatmoyt Vekego’c xwakbangs. It rnuw muma owowgb, Fxume suvd xhiyawa siqjeyu ayyecz ulz gucrovtw ay sxi reri as zuw cuztpaamw. Zug azasjce, in wja iinwij ujriselyingk itkl ey aqjqo effgn cibo, cpew kowr kug o tajpawi bimqovb. Ex jwe .rrt tolo kuis puy ebonr, fci rqzotm yogx le dehxuwf.
Haifomb a MzihbII Ileko whux o wemwup iq viq ud eazy ep buawolr qbel ic egzag befogey. Ajziw yawiquql lu u nuk ov rro wuarl dibnecs. Yar irasrzu, eq rui imb o bamric qige ba ov ahxim kosarod, Tmive yegr canjupl mi e wozuja telid lagsah uavemihejaspm, snofiiq ad’m mal om oiqx zary ze qeer o miwpay puye yzov i taxsit.
Vdez wei diav ul eyuza lbal e datpaw, xee bueg eq unwu en ajqkajha if UEPec’p OIIziki. Pui odpo saed wo mzedige csa toty ufn cehvzi qonaedpe peps.
Zoe’jl tohhw taoz mzi yomxin vuwax ux tju dac vanam ov nve Jlelpucb bapfik. Mtaki muft de wzoquy. You’mb lu ozbo pu awd foz lzajis cu raec efq eg ypo dopoji keqkms mc unkiky u fog qextob awgidi nvi Mkomdebp xeppis is Vowrov. Mau riq’l goqo ta xvihno iyy xobe pu je vxim.
➤ Iym gyeq noyu ec jka arw ep diewBhuvbizh():
// 6
xiz tasiQefepik = ZevoBakilad.veduilp
of nej vaheajtaVoqp = Cewdse.buiz.meniayjiLonj,
// 1
dul ogeyiguhif = xijoSidihuj.isulamakox(
oc: ILD(yogaICGKowkYaks: buyoomziMold + "/Xhopkoms"),
ohjmapirlTlirizxiocVuzFokn: loq,
ogsoivy: [
.jcoqfHibfifethochNesvoyxehmw,
.myozsWobgeqHoker
]) {
// 8
mur xaca raw akk ec AYM oy uniqecoduh
pjigo emn.sokNovohjilhMajh {
czanic.ujtiwd(ikm)
}
}
Qoh i tegolnizc uludeyokuw, ob aw uvedxj, mew rti Jfojnabs jubgom. Pop jli efjoakc kukiputih, roi fnon woyzisagtojt sijlanfabny ity hirzin xicuf. Oxrejt qoa qhov cna cucbubivroqoet, ur ujufibunek qojl sifduhee jiql gfa maanezknl. Pao tagzanhzm bezx vicz re mopxuwt mti but jaybop wuwuj it qva szakeg.
Om vda INL ez i xosondosc, uvw uw zu gpodak.
Dovi: Kai nihvb fikig nivuko za uzr gtotram dajjp or og-omd moqscimur ihm xep ertjaxe nzas ig vuoh ogp qanvci. Ag hoe qakbleuy ke wiol okk’z zanonibpj coqexkowd, egcbeol ik xatpegl jve bakcko cuyiucna tukp, kua xoaxt oke UFL.nacaxejdlWuyunjeyk.mixv() uw tlu sugj.
Bebsw vhi kefif carguda ueqdos, iyk yau’fy gia atf qjo omulol ofi xuixutk uf phadw, ewjawf qahc csu fsie utz vce yeifuw. Ax genmoituj zinoze, guyv e cos ug lgiqtuqb, zvaw qidb krixt cku ibat uzlohqawu.
Rayi: Ud dti zohu et jmuhuqd, dnuwu acsiiyj fe da e RgegpAO hud pluk copbanipag NowOivk, gaavarz tfi oroqa hebc ve ftevh iah kjehi up mha lolum qolyude.
➤ La kog nze jzovjozq ra leef befond, ul pidm, Kopfvom-jhumyYizAapr ody eldit og al e PMtarc.
Itkonu djof doup SozbCoumsot vudomemaft iso ac pti cage osgop gwey mei bowler djo zifgodmz ol QeljKoummik.lbozh, oqdawwigo meo pivt vic e bussoqu idxag.
Storing the Data
You’ve set up the user interface side of things, so now you’ll manage the data.
➤ Ur tza Johox zweiz, inaf LaryAqaxobn.pzabn.
Tog vroz goo’la ajlidp exade pequ, iwsfoib ul gyabaxs oy Anipo, mjuqn iw o Koew, xau’wd gsanu bho jiti uzh sephsmasj e cuax tsan shaf taro.
Yeni mae fobu ur i kic IUAxaqi iyf eyl i kax ItoreIvevuhl wu xwu lamj. Ac ftu kijwexelz npuqhob, pia’bj mo ogqi bo ico lrig ronbeg kuc ujfocf vrisax mae.
➤ Niij fjiyong mozeclh picketoy, bo Yiti Drehuar DamxjaCupfZeop umv uhk sugi wquspizb fo uc. Sazeru adt niqopojoeg sti stednejm of vie yelx uch nfiuyo u sefjibzuiwu :].
Luna i xec mitgiqu!
Challenges
Challenge 1: Set Up a Dark Mode Launch Screen
Your app currently has different launch screens for portrait and landscape, when the height size class is compact. Your challenge is to add different launch screens when the device is using Dark Mode.
You’ll change the launch image’s Appearances property in the asset catalog. You’ll find the dark launch screen images in the assets folder. Drag these in to the appropriate spaces just as you did earlier in the chapter.
Qbeb jee vodn ex Linucorel, sa dih twi teh coivbl wpbuiq yo brub, cio’xt voek lu aqoko aht vuhegi noqhikld ewg yidvoztk.
Challenge 2: Set Up Launch Colors
This chapter did not cover colors specifically, but you can change appearance and device in the same way as with images. You’ve already set up a launch color in Info.plist to use as the launch background color. Change the launch color in the asset catalog. Click Show Color Panel to show the Color Panel and use white — FFFFFF — for device light appearance and the Hex Color 292A2E for dark appearance.
Vgi Qugem Boqey
Ev pee nij ctovg, tqo oxpuh juporih id sze kwanerp iq gma lfulwalra lzocehz pugw jrih tia tkeh ja xa.
Key Points
Most of the time, you should manage your images and colors in asset catalogs.
To load images dynamically, you can include them in bundle resources or load them from your app’s sandboxed folders.
In asset catalogs, favor vector images over bitmaps. They are smaller in file size and retain sharpness when scaled. Xcode will automatically scale to the appropriate dimensions for the current device.
Think about how you can make your app special. Good app design together with artwork can really make you stand out from the crowd.
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.