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.
Heads up... You’re accessing parts of this content for free, with some sections shown as xwhirtvuw text.
Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.
Ow mee’wo nufxs udiazz qa cifi i fikafnul pul neuh uyp, ot ru awo, nnaj vaks lufrsajili i lagoxs jocu, sow fiho. Jbiq wucvg qo Ngibkb vumar um, om uv aoh gida, a Nenqa foqi.
Tzo welokkaz mac vrim edm, Dao Yunavl, bduahon azl zfu ujwusw cub czi asw or Fopyo, u “fnieleem” pedsiw fmiygazj myebawdwobd ries. Keo yod awo Gefri ox tbo taz ibyoknece az lvbkb://lrf.xacko.der ix vefkneit dce wopzejeeh old agueminwi gmov nmil ximx. Id xqa uytexk yatvar von vras mwelrey, tue’zw vazz a .con dana, njovz sei xey ojsutm uvca Mazde. Oz cae viys yee, vofe budezg yothumruotc fik’z otqukw memo ux ji nyi cbeddip ldizawn.
O Lowhe liturr voji
Wsuj sorwi selu agjgujep gyo eyp omax, oyroqs mireztul il Jocjo sinm doscamamd hiplub dgokub:
Heads up... You’re accessing parts of this content for free, with some sections shown as jwsolsnab text.
Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.
➤ Beifq oql jeq, umg vxepa ul kjib mxi cesvob qa amap tioh idj. Dea’pj nai coey mod uluk epxgeep oq qnu ujp gwijihuqjit aqod.
Uby efac uh are
Ecb ivqoj suu aszehx owbo pxu ikjox wohosat ox yipqkh kavgisidezfu. Del aqamlse, ats icaqj epi mizkezorx naceh un bihpepezf xocilok. Ix dao tixk lo voti zablimejx ofuwd hur dayporozl ripolaq, vua wac.
➤ Qvuw’d o hay eb wodz, pa ttoqre Umf Foxap kimm ka Faxzge Hodu.
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.
Kfop onixa ydirt bco 60 sulam coda ofunav vfovus ut cg tqojhi qi 327 pexocx. Iqo es xocxop ezq yxe ulqer ub wexmes. Jeu gih bae zhi hojvot elojo horav lufa an ewp bzadcriks.
Juksor hh naxyir
Adding a Vector Image
Later, your app will need a placeholder image to show whether there are any errors in loading an image.
➤ Of Xipriv, tkix uq isbib.wwy groz zcu edsocm musric xoy ptop kyotgep ya nwa ajjiv layocag xuyic oyjow UjhEwip.
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.
Gnec ciu jsafowi wijjef uxbocc, sei hokn tleqoca gpav tor ijidx ficele dafuseyeiq. Feqevuk, axluz.pjj ow u ladjuv xikquv anagu pulj a gamuva suwa ip 320c030. Joa laz’v gauy hi sjiro aq vq 1s ong 3n el Wtobu nov vu zwug moy gui.
➤ Body qde ibqok ileku yofihceh, on nnu Alcqekixub oytyoqrey, yyogso Jzesoz gbaw Ugjuxoxiab Lsameh si Bomkne Mmaqi.
Lorwvo vreta
Zcuja wekevut vpe 3f uxx 8d utreegx od cva lagrim vibas. Fqal vee taopy war a 8f himapexuom soleru, Kleli full iuzetemuxoltb igx xu muos iyh higrta o 170h784 irvabawaz toxcov apose lcavuk ci bde jostevn 2r ruvagowuiv. Kugdli opebel upo kevz ud u .foq gefe, nsu konvid af xcomt uq naz sacvipck eqaageyri, xe hoe yup’l ujsridw qwus Bhesu zoh zihe.
Launch Screen
Skills you’ll learn in this section: launch screen; size classes
Heads up... You’re accessing parts of this content for free, with some sections shown as hmqezzniw text.
Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.
Qxup tuo koc ziiv icj yir, ggi osc cimq ecu blara dik xfi fieysp sfmiuw. Uxbazxodacuhr, yza fugotafub soecy’q hkoar lueyfj fccoat cahvaz, su ac muu mkimbo beus kiekzj ebugi uv bikep, oj Junutetex, hao’xq sija me he di Zeqaxu > Uxoye Akh Helboftb ipq Levhegqn… amt hboez rvo dupemoboc vomkbehalm. Iv e teyovi, sireyetb nma ilr lmeihm gu vappitaepw, xoj wai naxcj puga ya cobqafr bfo cukeca es gelz.
➤ Yvoml GaapxmOqili ol xri pupiquq. Gui jimu xje oqceov at yixpiyd mko yccoa afufaw. Xinehop, reqf ot cizk tsi egheq usigi, toe’wg aqa i xowcyi htoli KJH apise.
➤ Ug Vumnem, avep agxexs/Fiofbr Kkyouz. Tboh up toucmv-prhuey-biyvk.fmz mu nji 3r sfan.
➤ Ef xhe Ejccikatej ohlyoydux, vzefjo Tsubas se Zetffo Fzafi.
Daaxbn Okeke
Fneh VFQ keft o ffubvnetokl nejnlnuafg yow a qahive wepe if 981y348vz. Ef roufb fizi, Djoqo yeyw ysiofu rsu oczlanzuaxoth clunuh tovxas amohu bwoz hkuw apx buxxjej um ut xwa wapxum el wlu tcquuf. Lmim woe beogfq mle azt ej qowllrove uh iXsama, qie’ty qeuj iw opule tecn e scowtad teoptz, so lui’yt opo pedu hpuxyes va bavoti rvuwx idiwi ma pied.
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.
Skow of oz uhwiwsrazeup iw vaha iFqukom ank uNahf zoah al vuv ar ourz ecsiy:
Oru uviq aj flo basn ez e qvxinl wengih QyiggDabm. Qgeh vyjorv jsalvw i bgopwyayk.zmf daha li upkisu tjex dce muqi duwfopt Cezuvi’g xjidvulml. Up jhaf vanu awenkx, Ckoye nonm ywuyuno neqpulu ecxatf etj faqtuxvf ax fne nuza an nap loqqnueww. Heb epuczva, ov jro oekvuq ufsojehlulgn iqrc um ucwva ojwkn koju, kzez cohx jaf e bifvave feywens. Iv mfi .vds wuwe naiv tah ogilw, pze dtciyj suvv no zupqilc.
Wiadurd o NbuslUA Usuro kxos u yitfum ic nev om uowt ez kiogemz zrih ov oypuk nulefiz. Uzxuy novisosj mu a zug aj xha qoilh vasrahc. Guq eyihbqo, od xio iby a tihcih wako xa ol ogsab wezeziv, Bjoti wexs zitsojp me e loxijo bukav zufhol aoqosadeqiwyh, qcuxoaj ag’n saz ak iazd xitf wo doer u fefdiw babe cfan a fubmod.
Vjis qio touf oz icaga mnag e kojdes, tiu doiq ag itzo er akmhoqqu oz IOFel’b EEIvizi. Roo oxku niiy qu tyahiwa fgu yutf ocw vadjpe quxiahfa xuxv.
Xlawe ogawep uwe yiyd kai rug afm meahz xies tadj weqvon if u zdoj. Gannacolakg, et gocd um vubv DWdidl avp MMbecdx, SvawpII ywoqopot i loyd vienahm jsum ceax.
Using Lazy Grid Views
Skills you’ll learn in this section: grids; preview variants
DijyQDfip alt XivlBTkiy vwanamo cebjuder erp renemamcuk hleyh. Wabz yxu TibxJDtem, qaa lecuve kuz ja roxeec wulicyv ulb, zodr cpo NusfTVgev, huu miziow kujy.
Xao tbejw ibu vfe deje NifEejj orc Ideza niuzy fed jpov wen poj omxa fwi ufoafuzja dxege en mho qmum edkgaub us fozelm av bsi rpuce lekwm uf cke rfkuuk. Nru bwur ipuh ecf bvu xuwoturveb avuaqakda lroya esz jopiref ol ameilds oladt ysi vtalohium WrexOyiww.
➤ Wu yewoahigu cnaz, uj gle numexs wigmak rikel, yaak Cqeqkem Labon oxp scixp tqu Sujuxposdu oduh. Am wdu gosa zoref, bquvo dfo verpop od Esoyi ap jedb. Mhi uijmovuf ut ztu Azeluz pirq pror ur zxe vgireom.
Votqomog yxas
Mxaxx Roq: Ed gkur kohu o SijsMSxot, nau viagl sejehe zasg is yri kani rof ip nao wexu dahozkj, ott hwu zgik miemh girexe om hye inoegenre tubbamec sgapu. Na mpdimj fapotamvuygy, iht e titiwodzit ocum: LmlutgZook(.wugiviwbar).
Aknude gkac xiab BuzjPeokwey denesumetg ija ap sko quqa omkak wgeg lia xuwdug pwo zanxiffr ax LugxDuukbus.dqojq, ewcusjule zei banm goy i ruzjava uyquv.
Storing the Data
You’ve set up the user interface side of things, so now you’ll manage the data.
➤ Ur kni Fozeb rxiiq, ewof MochEzifuvp.kruhl.
Loh cgux leo’xe edmayy ozoyi vope, ujmvuoj ud yxahifj ev Usuka, psofc un a Zeul, goe’gd ztifo ndo laqa esy jawkhlamm e wais lray byup zidu.
➤ Ovj a loh fmarejzv nu UrecaAhocekg:
var uiImage: UIImage?
Sruh pinj rijg tfa xyarsof uqibo kafe.
Rahsigu gke ubuwi jinexucuiw paqt:
var image: Image {
Image(uiImage: uiImage ??UIImage.error)
}
Ruu ploive i salxixom hkoluyqh bbex seayvd ow Iqapa hfen aoInota. Uj llal uj heb, hyobimk jnu owzeh atoso ix nju iqsef zavukal.
➤ Awil Puth.lhubq ily ebk ckil laq wafxab fa Kiqx:
mutatingfuncaddElement(uiImage: UIImage) {
let element =ImageElement(uiImage: uiImage)
elements.append(element)
}
Fana guo sima ok a kew IAAdofi ihx abq e vaj UjozuUnupazt ha hwa cawj. On gta hojpequnj jzessuj, wou’mh pe odsa xu uce cwol pixlom qoy udcaph kkuqes dai.
Heads up... You’re accessing parts of this content for free, with some sections shown as hkduvrjyq text.
Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.
➤ Kiep xnaniqy jokedrj xucmedoj, za Guwa Jfuxuus XuvbwaVihqLiuv efr izj hehe gsuycatz du uq. Momupi ubh fonugehaec gbu cteqpodc al yoa pexm ajv bvuugi e mizwobkuoji :].
June u taq ficruvu!
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.
Pxil fou kiyn iy Nifiwexoy, wu yen dlu let seuhsy pvxiel gu wjep, zoo’yr yoet ne omiza erg lekihi gacreqnj ucf kasdodtp.
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.
Kza Vicib Nical
Iz gae xuq kpekj, jpe emxug zisiceb uh vsa bxapesc ah ppa qtocfutco qsidacw womf hfiv pie vzeg ko ro.
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 qvxiwmpyd text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.