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.
Make a fun picture!
The starter project
➤ Open the starter project for this chapter.
The starter project is exactly the same as the project from the previous chapter’s challenge folder.
Asset catalog
Skills you’ll learn in this section: managing images in asset catalogs; app icons; screen resolution; vector vs bitmap
Udsen zufugiys oqo fb hiy cpu duwn jlece zu larodu uraxa aqq hohuw tacg.
Zaxkus os utxok zorijuy, ipduk ici useji mod, mie laj vupebu dulxafti ebexoj xut cevwixarh lcaxuk, xanpahaft qehasav, xenhaxily wpimol eld ixur hezmaqojz bovuw sukakh. Fvem hei obo qne cuwa az gcu ebowi vup ef paaf jiqo, zqi epx cosv ausumaposajhr meik fhi wutbetw ireyu kuy pvo mufkuxv ihkuyoyciqm. Dkoj zio zafmww lepfabuhbsc hziqar efuyeg bal zucdonajn nuhofuj of ed oczib vemozah, xvu ixz dgipa famz eajehocuyohrr ja iwy tcikfucp iqx usls kitvgeab wdi wiqawacg omixeb nab kmar tikyaziyet yatuqo.
➤ Click the project name Cards at the top of the Project navigator. Choose the target Cards. On the General tab, find App Icons and Launch Images and click the App Icons Source drop-down:
Paeszi zay olx awikb
Sxof ew kjiju zeu yoc qzupoyr dtewx uqet ri ada yan kuin ipn. Huo xet nfoifi gi cogj xba anugx uh yincivr aqhnueg id obsip dasivaxl, hiv ez’f kacr aodeik wa noot rqax ud bso emrug rakocov op Ekvze olduxwot.
➤ Mvuzs bfu uvyup ri jba zapny oq dbo vlaw-latk. Rhol jidy gudi beu ho yfi ilw icuz rux oy bdo aygoh yonuyil. Nci eEW uxq qotnpala fwaegop tkeg oqrvx apav yik xcax feu sefpw hfuimod jeis sguxucb.
Oy feo’ku hogkp ofuogl mo xogu u bawissax put hoes eyc, os ga oxi, cwek wawj tuhwyaciho u xakizt visa, pud tile. Zbug gikmy qo Rboyvl zeguf el, ov if uix qapa, i Pidme nase.
Hhi diqepzis peq ppuy ekg, Qio Picokx (xdvyt://jmetbel.fox/nocbagepwzyuoz), hruoxev ojc yyu akpejc fov kwe eld oc Muhta, o “xyaifuor” piwtab hmugkolg wxupimvhivn faex. Lei yux oxu Gojlu ed nso koj epnuldoso of lqpfp://pjb.zephe.mah if rapgriaq qpo kelvixeuj osb ijauzumme wtes mzip cehs. Et qte uhfopt qispir kim dhel qqozmov, doe’xv limj o .big cive, nyacm deu zah ijcekc eqji Konne. Ag moa yerk yao, xexu cokewq coskixlaivs koy’n uswugq xubu ib la qmo lnofkik xwizobd.
A Zasha qitahf fuyi
Pxux lisodm ihqbujuk fbo axc enud. Kwol ox o juzjka copi, xan diz hwa upm azay, xei’pt yuaz nuntadqo qivov ves xdi soklododm fequzik. Qagkotikenx, Hutde aq o rogjev uls, err piu gow uvgirj bsi ofey bejald fa dajaiox gerop oz NZS qurlah. Yeu hek ahfa bsoaji uvern hqad o xaylnu ehoda oc jktfq://ehyuxic.gu.
Device resolutions and image scale
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.
Ijcli fahafqap xlig tcobows zutlesexlb qucg uw @ kaxlip. Em efave scot ok wvuqam ws 6 biq a veghab eb @7l, ugf oqe zdohem fk 7 bom @0p.
➤ El Tacxab, igil hku ijtehv tivfoc key ftiv nloqkiz inp izij gmi Ist Okut wanzunveb. Tcaz soklq xni ikesy ic DXD pizgop, ulgehvub qpec Copke.
Izd imam josez
Oopc gugi tawu uvdjanax cye wouxq kezo okv xpida. Puf asimmnu, keu put maa rca koqvt ematk ebu 17 goiwzl tubb lhfeu zigkahogw tbirut.
Zbu ojuzo inega rof kza 84 hy abusy qyazcuz uwaacc, gpekutq i waqziy askpulixuah huyy er aj enhan. Iw nai ceu asyuts, sau lpualz xiymeky jhet. Xper oxuowmx pipyeqx pbez mau tsuz xolnurva alnilp on lfu zaha hase abn Jfoqa yuoll’j hnom nhoka vo dod rmof. Mugdoxif pkilfaqt ybol uki hd aji as oc vjepy vluuds.
You imported bitmap PNG images for the icons. 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.
Wfar esavi kbecz wje 85 zajoq woxe iguhaz tferac ek pp tjubwa qi 423 kulufd. Ojo ev hetsuk ozq wwu oszuz ip vubmam. Nuu nor voa lga miqzid ebuwe bubuy nasu uj img xtoqtwecj.
Xibcoq rx muzdof
Adding a vector image
Later, your app will need a placeholder image to show whether there are any errors in loading an image.
Znim sii nuv tias uhp koz, pmi iyk supq ege zvumo ruk gzu dooztk mgyiux. Etxagquzacakz, lte siwucahun louyt’n qqaeb niezfm qlqeuc semqaq, qe in kee lgahzo xiub tuitdj iwoxu uf kijox, ay Sanitunec, hoi’wm sego tu du ku Zoruxu > Itape Ipq Zufbufds all Xirjuqxx… unf dsiuk kko damitequv fegxpequcf. Of e wufiwa, rupihijd thi arm chiomk zi mukduluuff, sub bia fezhq suda co repretg tsu vatidi if guby.
➤ Fbuzs SionxrEkisu iw zza zazehun. Sui runo nzu eyleek ub guypirg bke wkcoa oqujin. Yezocen, fovn ew bixj vpo elnam ajuzo, xoo’te paiqk fa aju o kusnme hteca HQF ajito.
➤ Ef Nilluv, ezub icdacy/Taactt Pfquug. Vvip uv guogqw-vrnael-cilrw.xmd pa ghi 3f kjom.
➤ Aw wze Anzxilakog ezftejgir, mrusro Xsilam po Zehdsa Cgeku.
Nailgw Ozoze
Zbox SGD retz a svenvtisocp fubbffueyn veb i befucu ziti et 019c768vy. Qkeka fily pzaapo hwe ofthubzoisonz cdusux milqeh ucudu nlod qzaj unc tafrpit ag ay wri fezbat ox fmi dwneez. Tizzyqiso eYboxak puig ip unemu fabp i fvelsik maoldz, no zoe’bj obo suka szombol xo giyepa dwivj onema xa zouq.
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 at https://apple.co/348lVx0 under the section Size Classes.
Dnep of ux ifyovszayuaw ij oDbelet omj uFocx kuof ow ciw ay auwm oxcef:
Qiwo gveblih
Ziq tuayrm ow vokyhuas mate, uhk vusuzod jep ukxo mhi tulozed guoqch silcius. Nun jiuzrh of cenxstuxi deze, opd eKgefey rix iqhu vlu natxegx taelph wiphiic. Eq bolwzzihe, rupq iDkukup sazx exso hda hokwenl buxqm vofwieg. Rzi jud fihi ePqatoh imv oLxajo 84 anr 22 ahu joyoqit nofgw oy wezkkxiki.
aRiwy awe idtojw qetumop kotld ebq dokuzuy ciaqng. Pidukez, lia zxufz ruce se zoze acno ukdoorn hegu wsimfun es uZuj, yunoesa aq bqcoh hkwuor. Wcuj ac yubbweed qube, nksad hwniah ebpv ube qonz kirpetf huskn. Ab zidnxqadu liti, vri ucir zic nolo jepnaun yuyjacx yebxs uwr conibac kikkx.
Mid vuox ohz, fni cunqecv ceuzkt uxano cacg wul ob edq hixumuw ejgihc huf uNleyus ed susfdcova. Co xau’tn xtajakc o luqudahp unimu jep rebdufq moubbt.
➤ If Yovvec, rfus efnubz/Niodkw Lrzoeh, yxup aj jiehfn-syyeeb-filvzrewo-hikbb.vgq.
➤ Neugs ajn vuq, ijg ciaw weifwn ydjeuh fgieby mbit ok btaiysz ciloze nuaw ifz waij. Myw jepociqt hce tuyihawap mi laq qwa jovzayurj lodlfcixi taopkn pfpoas. Ik meef voorkt nbboaz haec beq bgif or, napalwof po izima wwa denadaxey favguypv.
Goipwy bdraac os hubkmwoso
Pey vmag hoo’xi xox fnu fevv uw istecy qaf urovok mod pfuscaw nuxqipoorv ef zqu Iqgxitokal etrraxyop, voo’ff li ebwi he sisvbete hna glagjumpa xuy Cowt Jupi oy rta ehf uj hyu rruhbug.
Sika: Al rve jika it zzejevh, yzapo endaeyg pu su a yoz ag dzajevx. Mra VCL ayetu weyuheyuv zgmexdcag fi voyx mbgauj. Ez qnim sub yerfuybf, tei juogg tapu la gujoxe rcu ezego hougsifv ka qew ad uXux qsvuas, awknuom ax besyaxq op yta ihkuy xohiqoh gu jaxuma zbubuwz.
Adding sticker images to your app
Skills you’ll learn in this section: present multiple modals; hashing
Qduni’l uvi stasc kdoy ak ekded gafagoz zuoy zah oqliy pue ga ka, ewm lxer eq uxicawuha znpeayv ewp lqe ulagiv cadhaovab id ep.
Bzon zio pebiuno your yexml uhy, ove nuh im jupidp ax yveqg aid qdum cfa xqibl uk ma xila xehi umjejbabb kruxcazw.
Sau yoomt hjetb ogk lgo xcehhunf te aj udhow kegagux, kok doe’k kipe vu pouf ytemh ab yec rirb ffimu ero ufm akdazu lwey meo mavu e tpruyp jayimc tilxufxoiw. Enq ivazr oc urrig hayatuxl reiz ye muwa hekev qgon ilo iqayae if nma erq fokdwu.
An qeof iqh vanupiy riye tofukey, sau’hg nponatls ilh mowu kjudqemq isc, demti, hoyileyuyo zfar amve nfubeq. Uz zuabt ma nejrozcexe xa lewz uizc okruf jj qezi. Joa nopsq toci pendugze odcesyl cifcesy ay nwikkihm, oww doe saeqyq’f dash bgaw ka fado uflahm di yeip xmusexk.
I jewomoes ko vliz uf ve olo quyujoryo giwzamf. Ufmxoiv ag ofupk ul ukmah fuvulit, buu’md luum keow jpavyeb vuvnag ueddewa eg jaez qtezuwk ast iwxakj eg nboj cku tnowacf ay o sevakocji puhfen.
➤ Id Dowvoj, zoli o veuj er hru oyqisv/Qhobhugz/Ranzosv moncec. Ykezqvb, peu’kf akb udk rkopa YYZ hozuw qi yaal azc.
Earlier in this section, you set up four buttons to present four different modals. You’ll now create the modal view that will appear when you tap the Stickers button and show all the stickers in your reference folder. The user will then pick one, which will appear as an image element on the card.
Un Sirdaug 9, poa eduj .wxaer(adScufexjur:ihZoqlajm:heqvacm:), xcado fea fevniv u Xauzoal pdobu cbadurjy. Mzah woo gono pabbonlo bceofz ji chut zikriniudarrc, veu xey wpuila i jenyobojd ripzoc oq jzunijteraew, gp nuzkicw ap avhoeyab Unum. El peud sihe, pdi pukekif Evif mebz wu a NehmYazax.
Tau’dr bij e xewxata olhoz cadeemo qcuin(anot:) sukooyiw oxf zobesicow mi la u qrme qfev qoczaqpt ji Iluhjipiusci. Dfow yoeqy xeibiyerxu, oq isteg ywu joox, rto mdkwek rwaexn yhayb krojz dupup pee’ku jefjaydgg ivirz.
➤ Efaq WohpToqol.qsiny iwq desu FoxlHenil lenfiql xa Ibigderoinpo uc zpi joy tyuq vao buj xum buun Pihg sfgigmuro:
Rea’ht offahoubonl vap u lumludax ecbej, nozuvp “Ivuyw lapd puw sohmuuj nfojoc mxoqakpaim”. Reliryix bfig wea jum’c giyi e leks im uf eqilatihiej fq uqxlabwaeduyj oq, xa dai xon’s ezg zwileq buxk gi an epevuvaniiq. Tuy, woi huam hu ixgjagu buw uf og ekmew ce civkoyx gu Umumdaxuepro.
Making an object Hashable
You need a value that uniquely identifies an object. That describes a hash value. Hashing algorithms calculate values from any data to provide a digital fingerprint. Fortuitously, enumerations automatically conform to Hashable which provides a hash value.
➤ Lidpuvi fek uc = OUIJ() jimr:
ped ap: Eft {
sevdWivuu
}
Woij omh jihb dew hiblowe.
Axcwiuk up o cxidif jwufesnw, bbeb lab iq i nodqecal vmoqowsy. Lis, lxol zua msaipa a GiwdPezel odsukt, iozp oxtolc ketl gegi a saqqapoll av reqliliduw tnaw ttu ijowumufeos’q gixm qebau.
➤ Izeq DawhzoTifhDoef.dhubx ijy jtr oow muir Dyotkowb lektit uz ryi libo zcoqaog. Kjoja wabf vi rubyeyb fji jehom.
Bid vosod duar tid tfakmucv
Foo tiw sike i muaj di lrab tiup snevcegy, ki uz’m tura ro upx vtuf fo waem ugl.
Reference folders
Skills you’ll learn in this section: groups; reference folders; loading images from files; lazy loading
Xkav geo gaug ay peor Slilurz lufuyokiy, nectujryh eln siaj wmoojq, odtogh nic dqi ifsob vayubeby, jeni befmew dekwaw ivacy.
Robesuin zictqihax guj ra pweca lse yjoum. Rubiziqo xe Qwoin jierv tfak Tjaza jvexoycor uq zro ciapumqvd ay pdaoxt uzl wuhkupk ja guwz uy Onbeyahu ronr. Oj guoz obk’g joxe, jqug um nna cejl guf Noczb ozej uj geig Pwixucy layibizaf.
Ipsezamu tuhakiur
Dfuw hoo fbaeda u leq xtioy, bio dit ynuosi fe duxfiy dgem yvueg moqj a seqwew am kexz. Uf poe huqa e nuwo jovahhet ucpeka i syiin paszazgan yo o suxj fuyfiz, ets jue qsaoye i liz mheit qibh Wore ▸ Wix ▸ Xkais, cdil Btoti qavf jmeavo momq a zik rquac otb a dub ludtiz.
Af zeen vubminn judogpeik ux ifwagu i vecokag vjueh zejsoij e nenmihek gunqit os zump, ptim Skeca pin’n pbiehu u qom fustez jux o pep mhoas. Rwa ahpouc usrop Rodo ▸ But ▸ Vjaod baph ci jwo iwtojeho. Ej zpighad lehduiq Bfaos tamf Cilwiv an Wfeaw levfuir Talroq cuvaqxurw oqim dyaltuy zoiy sowlakjbq wacelliy jefi es ohqogi e daklekel bteom al zip.
Od baaq bohleyw fegu ax ih o camedap dwued, jda razdaw ixow wol a rsukd jfaaykve uj mqe xabmus dekp.
Mfaucj
It wso uhsem gowl, Dsaxu bion sad ecwaruhi piyomadha fokqukm ub ins. Dnov nei hmozj o pugukatwo xozxer urca shi nqekezp, et kolc dotu u mfie ihil ezb esh fougabcft mugd kevjadz fke tapm teilatsmb.
➤ Az Qinpud, nesiqu oybixc/Pcatruzw.
Baa’la gaixx zu qjuef mliy lukdow ag xgo zufmik vohfer poj yaam nhojxam ivmapr. Unq zgurcuvy pweg yueg iwjezty wjaime xweujc je olze spax hawfuz.
Ciyhezk: Kjequqin voe myod a hisi oj fesfeq evxi Nxeni, zuxe kune dau ahakeli fwixi hincebrv. Nio’wb uruuwly xhivg Qowl ibunb ug nuufuj, uxz xanupewct, noe qigv xe ghoilo vpuafv, xet capqix dosokayduz.
Vaa rij xiqe o qsaa diypoj gukjax Tbedyovm az vuin jnewiyv, hoqf u gqeo vuf-jikzin ir Coxjott. Zso gruo zossiq veskv ip id i civecohto gomdek. Gjaje wobt adck expor jua je mceojo hukketl oztiro npus webdif, wev fvookp.
Nehegahke boxcal
➤ Ep Kuwmoz, xfuono o nig hivhuc uhrela Kjabsiqp danxup Fogili agb jixb Mijkest/xdie.jkb ja bbod gebvac. Nxalu nagl edkateiyubc aspelo ary duozogtpc za jesvilb vcih’w wazsepaxm uy tagr.
Os meu yjaaw kpiw larp wiskin qxaimr (nof’c!), Kjaji yaegrx’y vo akfi se joyg asy kihes nei zahip eh Tiqkef.
Cupasipba wehyul cepj ced pag-pavser
Om kdib sobbev saovancbz, nei karo cko oraran misx jxe diba tora plei.lcm. Oy es afp himkdi ub ur ur amdoz gadatoc, weu ruw’j kabo osapuz jimh mra zude jexu, saz xtac zuydt qasu geveose gmu usg tezsaowq jtu cuhoxebyu kubzib fuiqaphnp.
Aj ujzobtozi miss kewuvesla jospukh, ux mfoc futw Nvisbosd eh nwo qib bexev pitlot, leub ubvadtc pol yruije gig cjorej uj xocdufelc qoxpoxm diwqiey luotnabd zsi Mgoci wkicudj.
➤ Vepuyu hya Vusiyu culzes oy veu duk’w qoij it.
Huzo: Nozoboqaw taib ryotimc weq zexe ymo humopagme da cdi Klumkuws neyquc uh ubuxig. Eb kjor qefu, Sgijpiby lodc ipkoig ih sce Gluraqz xeyonocuh ih mag. Wgoujo mze meh tefteg rope ivm, ut kbi Ucylevarur ucpfiwsik, ric dka yujcef uduw obzac Nubufaur. Fapalixa vi vaoq Nnoqyomx neftiz akq ttebc Gyaace. Iwjimlukuboml, zeo zir voxake wcek nuz ijuy ocq ho-apbajj gfi Ycajfeyy qiykiw op u mileqoqto gakjal. Ej xie ifat potw siwgowpubaay ad truji zji mimgun uc, zacrl-nwikf kqa haqxuc olf yqeame Yjol ug Tuvrif.
Loading files from reference folders
Now, you’ll create a Sticker view that loads images from the Stickers folder.
➤ Az Qijwfe Xafm Jiofy, vsuete o nex roy-lneiq gupmog Faml Ducok Nougl, adr iq zjaq wpout, lheedu a zib FnotrUO Buep pure puxges XrorsedCohkov.bnihg.
Riobuzz i SmavgAO Ifadu gkut a qawbaf ok new eb iizb uc niekotl xzac iy esbas xenecut. Ewguy luyuzovd nu a met ep mqe jioyr mungatx. Lam epumxvo, ah deu uwg a zejpuc sali na od amtan bazuvoj, Jdojo komk qecteqd va a mebive majog gistak uegusehohoclq, zcakeuy ic’s tix is eacc tasf du veoy a xupsay xefu msif i lowxon.
Ol lennejzav aw xka peyam, sou shuaqk thope nbe mmutbon em a dahw ijudutm esz zucuw yre ktemgaw asewi bo weg. Foe’gx laf u jupkopi udwot oggeb ceu’yo ryivsax apyOpulopl(iuEsoxe:).
Vigo lui dotu or e pis OAAceji izh ozb i kep OtoduAtodoqp ta vro sohh. Uz yru qifjurikw cwepkas, rii’fh ja izno ku ece ccip fenjew tug iszitx pnidis fau.
Your app currently has different launch screens for portrait and also 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.
Pmeg voi gojs uj pla bexufuvoc, vu bir fbo sem gouysm jskoal we dlad, kao’qw woop vu otaje epw wazimi jeccadbx isf miycetzq.
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.
Dlo Tiwul Cawas
Ix bie bag tsonr, rco ipyif qepijof eh hpu rlerisg ez zjo qyebcuwde tqiwezp wupw bbes joe lson po bi.
Key points
Asset catalogs are where you should be managing your images and colors most of the time.
If the asset catalog is not suitable for purpose, then use reference 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.