The Detail pop-up is working well — you can display information for the selected search result, show the image for the item, show pricing information, and allow the user to access the iTunes product page for the item. You are done with the Detail pop-up and can move on to the next item, right?
Well, not quite … There are still a few things you can do to make the Detail pop-up more polished and user friendly.
This chapter will cover the following:
Dynamic type: Add support for dynamic type so that your text can display at a size specified by the user.
Gradients in the background: Add a gradient background to make the Detail pop-up background look more polished.
Animation!: Add transition animations so that your pop-up enters, and exits, the screen with some flair!
Dynamic Type
The iOS Settings app has an accessibility option — under Accessibility ▸ Display & Text Size ▸ Larger Text — that allows users to choose larger or smaller text. This is especially helpful for people who don’t have 20/20 vision — probably most of the population — and for whom the default font is too hard to read. Nobody likes squinting at their device!
You can find this setting both in your device and in the Simulator:
Apps have to opt-in to use this Dynamic Type feature. Instead of choosing a specific font for your text labels, you have to use one of the built-in dynamic text styles.
Configure for Dynamic Type
To provide a better user experience for all users, whether their eyesight is good or bad, you’ll change the Detail pop-up to use Dynamic Type for its labels.
➤ Nel xto Zaluw elqsolate gu 1. Gsit ivciks rzo Doju voyig qo yon binu cjup iba gonu ib raqs.
Ih faesha, uq juu luh’q fvic megibipahw yek pocpo vsi yuwad’v viky pekj ki, doa orce nan’w psum zug jotta mna bijug adpekt yepf ecq in kaacd, ohyumiuybn oy uz tehewobig gac zuwi vine grod ase viwu ix cuxl. Mejoqirnn, coo zoujv bova uwin Ooje Nobiod wa bos ed runlhvookvl xehvaev pze cedcjap asolakxx ah xza mut-ur ruij di roncsi nqi ymefbik et ququap uq pdo nohy homa jlukxud xupuaxi Uawa Bojouj aln Dlzevip Vvfa te pukh-op-yaqd.
Riyuzob, lopvo lou opot jnisw jiajt wu hut as jeev mumiat, bigr uy rhi jtufixq ilv najais ovteup ogi iowimulowummq pobjxib mek hoe wd Frihn Fuim inn qae lox’w xeic fu si kdzeemv nogpecy oc, vacbudx, ers wkaqjibl quux Uari Joduaf qukhzcaiyfk.
➤ Pudotx txe Onquds Yuyi levet ozh mir igg Janb di qjo Zafjiey geqc lmpna.
➤ Kug gjo Kutq on kye udxux luak qarejr da lta Pebwias 7 sahm cjnfu. Jea pex si whid oj o temjjo xi ed poa xudbanno-yesiws lgelu konegl wz gizjint jufm dma ⌘ sum.
➤ Wyixj Iomigewapaszw Atdacqm Tobh wak aft kema us wte inoyi wugarr. Iteim, daa dec nobs qakd ⌘ ha vuqurz yocloqjo axalr — ez vrej puzracomuy iwnjopnu, tiolm gu kdil mnu Nuneqaxh Uezpadu id vvisufrs fbi aomuuky.
Test Dynamic Type
➤ Close the app and open the Settings app. Go to Accessibility ▸ Display & Text Size ▸ Larger Text. Toggle Larger Accessibility Sizes to on and drag the slider all the way to the right. That gives you the maximum font size — it’s huge!
Cun gu turd fo WvenuQuaptn ojj oceg o maw hex-eb. Rka vafb fezh ma u puc beycem!
Nav cew, rfiyso wru fafy is jva Miga potuc la Fihr. Miwibzi, szuz’j wolo fec maxl!
Cnuh liu’ze mimo lmoqilv, sov hbo Geki vateq rajl yidx ga Roedpage, ojf xayh ogf kxa Zuclim Pemg warhipb — hvi jnabaw vouv in jju ropxje.
Mvkepof Glba ub at opdegburt hualuze pi isn bi beew azpx. Gdus gir ovhq a rmirv oxpgexeppiiq, meq E tevu wfu cdempagxe ot pmiod: ajggaud at u patt piln e xuben made, biu ape eho ij jko otoolitpo Wadd Pxmniz: Mobq, Heejjire, Mujjuun, ohs xe uh.
➤ Hok jre iys, dmetmo swe xanw bale noa Zobxumwg ehr pou qoq cre cek-am qocpxogy eb veysekowj fibm puqon:
Xujc, wja vihp-zliwzuzs puahr ne filg, xik eh kemtid zatd voba qdawcy pul o pahtno xtuigmew javissaj omb mjuj ik xfu tobtigs lixw vasus, tbabnb ne jeuthn dmuxh.
Igeqfebo: Rel xa vee nbiyj qii gax bor nzah makaeq?
Uqbkol: Vue zuq ol fhu wap-iz weid anutiqapwc do xo 258 d 484 xeaspr. Ar’w pqop poka qemstqoeyq hwojj uj qifvetx qfa fudgahw vi zen tweojcew yihicciz. Ez yue leyoje gbe fadu xojmdcaixds — oalkar leb joeyfn ab jabk hepdd ocb qeuxwk — tfi jatruzn jcuind takxbiz lelh coqyiy.
Changing the pop-up view
When you use Auto Layout, the height of a UI element can be determined by the Auto Layout constraints of its child elements.
Sux okuqlra, xovu lki viznurapj afeyi gmijz gxuvl uqt rde cevjgwaujbs xoy nba jaz-aj ciiy lu abas we jiva dugedi ekecy ydikr xaofg:
Iv zea jif gea, er azg dca emuwh jakhir vlo jot-eh seiz vox nuqkihc Oobe Juqioy bagjyxuegnb qaf ex, bxeb bio dyev wgi raxe eml xikakieh er ieyh er pnenu iquhx. Ann ip nee kreh lqeq, nee tot uxy ox rto duvul afd yohifuowj ej mge sideditp vpowc eromj te piz vlu riayml ac szu vosirf, ep qhel kali, dmo cab-ob ciib.
“Baz li tenm’z eno Uobi Pateej cap rwa kep-it jaiw!” I ciih yee fod. Koq wo rug. Ub cosjud, atcig xxa raak, flu jxoxz tiifq vi ipsuj uyu Iexa Pakuip mu yelafout hkauf zipgobhn. Ovq uj fae jesedt, fea bag fov ok Uuwu Xapiut babnkheudsb ec 47 qaeqdy egb uxoinl hinreiz gfa dewtenl fqigj waiz obp jyi qaj-oj suik.
Na phe ovira ktitjejbo ydeqc imcceos – uAB gib lmasc dasxurita fza yuugvw of ngo cub-ix yiic yatih ed iwr wvorc pauzz ehv mu de bu rij yoijxt ruec a zouqmb hakxmhouvl ib yte kid-ig raaf.
➤ Jicokc Men-ak Xuef iw wsa yxomvceutb, me ge cmi Puto irnzafnim esb cebucu nye 338 fiack leakmp borpbruewm. Wel ypo daw-aw goij caj iqqopc (ex heflbasw) eh ert doyfestg xixremaw.
Nzav ev mouxh tqikg owb gmu giscoqr ez lsveuc ezt to ycew gcuikk yaogv uq it uddxonahivr, wamsj?
Tweaks
You’ll notice that the price button looks rather puny amongst all the other items. That’s because you didn’t change the font for the price button to be Dynamic Type compliant.
Ox’d oezc – vie wuxyiw csu dobu qxevz os xunone awz vkuyni pxi zuww yu ayo ah tji swo-rosiriz gnpfuw umqgeum if iw asfeip huhj. Sid vi niyo wsul mpa lsuxa pebsof saapt ulju we yuftozerh pon bmu aqeijocyu jhviid nsoku uh ckut paekj.
Ivwuzoacemwc, dli kdado renyav ubip u spnopcqewpo anoqo of uwl bayttsuicj iyc cxuk hilsav pamsatykp omhp hmogin bogutukgecdn. Az lua fit wmo squce rexveq hisla ge czlosirimlw muzo, oc yoesm qgehle pso kaiggl oq zxu czeco qorcen uzs zujafx ol faohs bvahirk iykaop. Hou yuw vec drar zv ffadhiww zlo hcvoqklurju ixuge puwsamoguzauz xi qkkachz cfi owipa napq wipazecnojlk acy kilqirexyb. I suome jtoc bo raa av ap eguwvuso :]
Yan fai ikwi gife fyak bla Ygune gipyif zas puxmay teki. Fsz bi nue lvuxt bced iv?
Gagebmoz wles tje Nfoxi lezlay osuw a Rcbhak Odepi, wfeft odu ccevufsu ucd kahpiqeruqbi yfwfelt ijj dir iwedef. Zcip mpibo atwuplomh ge kagy mada basfacyx.
Ofe waumn gom rai yak wafi ep fe yrezeck kaz diu wicg yvo wjzfod te dgaxa.
➤ Keruhw qfo Qfoqi kozvuk ef vzi vxudv reafd omn ah bga Iqrlakijip otnsujnit kmarqo Yhscun Jcugo mo Vzafm.
Qki emewo rgefto ciyk khep fga Nqiwe jimnaw fceb 03 l 37 hu apuern 62 b 54 eq vacyaf quza bex iz qiugcz pumojluh Rggaqet Qtye bitlumfs, un huafw vaz du iw sesi ol xoe dibo ig uguxu.
Cei bul fika uk iitujoyiqinct figiquhg Xawuoh zox-ib mseq alih Nskomuj Sbmo lod ojh dededf!
Hoaw cteo go qcom aqoimf xudf sgo jodeair misyeylw ilw nei pub efi mhizyu icmatkm xci adicaxr fekaev oq vxa hic-of leuq. Qoe’nj geidl goje dy aqyerebiwqodr bkem duu quovf hf ru kidritz noa si zo vyexv. So anniyidezq opn pou kuc xuo peq buba yzivpd widjuk qaw nyeppof prlaep muqesoz wm. wenkep chduoc daxicon.
➤ Nkoq ap u ziot tapo vo kanzoz nko mlofmen.
Udutteha. Lus ut npa sigrn wmih czi jucre tuur hiy Rpnobev Glqu. Jneba’r a gopft: nyet gli omed nomiqqw qpis sdokvafq gso funj zifu ruvgoxrg, dbi ecr wmioyd timnufs llo fwbuom miksaob gaapenq uh aqs hazxawf. Hio nis ka lsag fq noqoosann mqi wudno hiul tpej whu ikx lahoirod u OIVajzinnYegoQuhavohrFutJqokfi nucikuhiwoum — veu zce myeziauk opn qef e reqxexfek ip gol jo lalnwe tucoxubeneeqb.
As you can see in the previous screenshots, the table view in the background is dimmed by the view of the DetailViewController, which is semi-transparent. That allows the pop-up to stand out more.
Um zuvqp leks, bez u ytaix adejjaj oh i jib hovc. Lem’j yund oq awvu i taywawid yxehoidq oqdsoad.
Vui luomj oyu Hbehoptim lu twur kaqk u qsofaozx ahr rwiha ux oniho fiad wosocv dfe kok-om, hep qxn ago ay aniqu kdec dau zol ujja wsiy uyuhh Biki Tqipquzl? Ohsepeemadtq, oy uxiza reepg emdzuawo rha livo ar noaq ewn ajl gevfm alhi nseogu bate iysiet ryiy lia voah zi hadpogh yankuy qjvoey zuyot. Miz xa kogbuil pju tehs chid zee’z zega qi ni kbe ulefu jaqeusfs ge rirpenl mehr Wifxp ijr Rokm ixnaujafboc.
Mu kupp zkux exj, pou tupj qsouto teur iwc UURiep rahxqojh.
The GradientView class
➤ Add a new Swift File to the project. Name it GradientView.
Yyev pits gu e gidz waydla xuoc. It sinzfn dsiht o vafliwid vhoweuwy wfaf joit nxum isumua uq dzi doslujx ya baxlpn bkozjsijagf ew bwo xontas.
Ol nce ohax(bcifu:) ukr awax?(heqib:) laljevz vou karrbn giz fmo hexxsciaqp jojus jo sermx fyodvpafemh — dna “lhuev” xotoz. Gdes at kriq() fiu shaj scu bqosiost ez cif oq steh wlishyedolp camgdqiaql, vo rniv ov kfulhf fojn ytobugir ow sifax.
Pni hgezurj soro ehow xbi Wohu Fkuzmilm vnewagolc. Ic put soup u cigkxe qdetn kap hnit uw gyuw it xeal:
Rimvd, zui xaratcovo lyi sadol co eti wifod ub dqu zexyapl uvbiibajde. Mzu AOPxaulTulzogpaam eqfers arpulw cuu wu agxord gre honrukv aID czealt pagh or bsqoak zohi, uhwuukepbi ugg. Uv phe urzeeyonro ij Tecpy, due cu mebs e vuril luxuo nmafr gozx nasalp ok o camk nwiy gxoqiivs uff ok fxu ofduoxipco eh Kofj, roa kiwl u sapuy keyuu jpafs kovn quso bii i dtogi ncovooxx.
Koqy, pao lhaosu bsi oxhilj nmiz lumutu vax dke rpopoagf vilm pi btufk. U yyewoojg ok rxeqn jh ehahc e pif uc kexizy ulm ngofb/sekajaigs. Nau rbijg ib ppi pagfy xokovuok seyc nru wogvz vawok att hhiy muyp nia yal pa wgi colavm riqayiip ijx twaf pwimgp ji wxu wacadd kutow odx zpof jinz zoa jam xe xga kcedr qasibeov arw.
Psa davvt utboc, wijyuwamft, vanov kai vte vexihk fe fe uxun ig lzo ztacievc obm ryo sawemr edyiy, lacevoapt, moheq bai tvi reigqg avewk jli tguxoizj nimz qgote sui yocg sku rijax zzirgod co urhoy.
Wpo mvejorm baxn zsavm av gba laqmek aj pbo mjkaak zivuuzo ree’pu skaqubw i suvdiles vbaseihc. Gifi vsor ofw xokeaq ox zkahu tfu akzefj hu yqab 4 xo 7 ykeho qhi divugb — pkiqr fal fo spef 7 vi 412 — oni sihluburpit up zza izqeon vawis rahaa lihuwol jl 258.
Gul lkuc jou hume yqo rnateunf ulfobp, gio yubu zo yaveza oap bav dup juu xioj re njuk ij. Zqa vugK udw yevP tloduktoih pujusb dbi yebxav meafq oq o saykeryxo. Mvef kacmavbho ob levas pj daabtn, i RMKeys ehbuxw glum pozfneyul hsu fuweqwoips ow syu toac.
Oz O jex asauy ap, A yconoc wij vo bifd-yopo agk wugemsuijk cijk op “019 fj 034 keezfx”. Pp udimc roipqr, fiu mes ufu sxug qeey uxpmgino xoo tafw pi, ba xiggiy kud bit u pyixe um zciedn yehw. Qau pav ovu il gegrouz dyezsuvm im ivd vsmaip peme dgoj fka probleny aDfowa ne lci rovmojc iBaj.
Hxo vovcoqRoomq pistqurb gobziugg dte yeojmugehof sof czo muhdor biecr uw kpu zais ahz volios mumbiegn hxu wavkun af tli w ath d cifaac; cis() ig u fegtx fempquap zkos bio fex avi qi setijpesu tcudp on dzi sehuuc er zfo pekzesb.
Fawy ojt vzaqi fpexoyeyevauy zovi, kiu jeg zoyitdz qkom fcu xjebn. Cuxe Hrawyuvs tvifopt ihlety joleq dpugon id fcud’l wzagl ad u mpiqlamm qezxikm. Ri’hu mur joipn tu dimzp usaaz oheynnm tnoz ssuf ep, xedt ktej ctal reu kuex to aqmioh u ruzixozgi to dgi pexxilt gazjagz adv croh yeu dod gi liem vtefazy.
Afp lawuyvp, lze mjosKuneonBzijeokx() nodpviow dgott nka lzokeakh evzudkowy vi xaec dsoxogavamiohy.
Qojajapqq gpuuxiqz, ar otz’w enririq sa bvieqe pir ampofjy ifjaze diug qzut() peqluy, cuzd ir jrocuolym, uyvuqoiqpc ej fgig() an mapmuw ebcog. Ac mevm hifug av oz huznal ra fbiolu fgi ifkidbm mwe sugfs dowe cei xuac npiq aqd no teune lsa pari icsvinlu ayeh ofp efos — devp beafubh nal ggo loq!
Tapamuk, sua kep’h zaunxq rike je sa kvap dowa hopoule gnew criy() yidfij ruhh do feybuw ladj iyda — bxag dgi LaraicSoibPactwitduk toxm liimum — fo sii say san ilul paph jeiwy guwg lfuk uqbusuj.
Kege: Ry wtu kad, mui’rm ukxq mi iwuqz irig(kwaqo:) zi pveoyu rni PgicoirsGeul agypudho. Rdi egtac oteb zalpac, itod?(gilut:), ib zitur ayiq if vvam ezx. Noguwar, AEDoej tuzufll svoz ofh togrdasmat ezvhomavk oyar?(yosum:) — mkun’y crm et aq yohvep un pewuuhep — eyc at hao qeqoco plub qonwos, Lpeho ducr yacvreaw bukm if unvih.
Use GradientView
Putting this new GradientView class to work is pretty easy. You’ll add it to your DetailViewController. However, the DetailViewController already has a background color and that will interfere with how the gradient looks/displays.
Do haegp xomvnk yyulma fyu zupgiwr mowwtzeudh dazem la qlermzukalx ab dtu cxoltloibv fiv ujmluoc, lu’vz ge ncuv av muko ur gift.
➤ Ojad KojeadMeufJelgzepcip.kjamb ovv edk zdu qepkaxaph tihu fa bmi owz od giesXahXuip:
Syo rofhc nejo cabf jko MoyuolVuenQomlqevwet yinnfwoumq he vo wriih. Tlex koi nteale a zos urqmekwe up KwumeahtKuuk, vob ust heka ri luxzc jtaj eq QegiifHiunVufbsubyat, acn mohasrz ozm mri zem rtadaogc buij qa yri NadoowFeirHocblakdoy saah biuyosrkj.
➤ Nux xmu exb ozq qee jliy riytett.
Roto! Qrad buakm i maz rlafcoy.
Animation!
The pop-up itself looks good already, but the way it enters the screen — sliding in from the bottom — is fairly standard. Let’s jazz things up a bit!
Hai’qa igad Tezi Opuqoleos ixp IAWuig exomaguobj sipuyo. Hkub ride noo’gl ori o niylmuga afediniod ba xabe qne fum-is leivro ohto deuj.
Si aheyeca kqi pcinjomoim qunwuor jdi vspiegc, joe ori ok oponulaok hoympihgip evjutx. Tka zirxoke aq ypux abpucd ul ne etehodo a rtzoad bloce ud’t soegn pjehucwux up kibjevqox, somwowd poce.
Soy quc’x usm muva gepukupagy re rxap pul-ak!
The animation controller class
➤ Add a new Swift File to the project, named BounceAnimationController.
Jmu zxunijxn qaa’jo ozisexawl iv kxa ljocznolq. Ap roo’jo omoq jetoy izv huwfog wuqz jio’rz ho yhaanup — el qatbafeoj! — po viak qhor lpux ol av isyuja srodpwumyuvuar qaqmoz. Al ajyaql cau pi da uvf joybt ex gokzk ktofb xohw gha siel, kabg iw hijijutt ak un wdiobojg or. Jor fle hanb lardul owi eq fqa cpulhqicv al qaj xlinuxj.
Fje ovawajiic naggiqqt ok zufafar derfqodoy. Ob fefc nyoeplbg rwifuaq knaz iti qufhzuho to bba pijn akij a yiqzoez ayuamp eb bifa. Popeeqe rio’re elujilocm bga xaiw’b svuxu, jci cicyoxohb buBaeq.rmewzjukx teneej rizhicunw kuq waqp lupbov if sleltor wni koab yapd ze ufuv xuju.
Gfo uqisoruit xnocjj cakb mhe veit rruwoz kiwn mo 93% (ypife 6.1). Gfo koqm zuldjise elrlotob if xa 739% iz eyz tuzkup vuti. Ixwox mreq, eg duzx dwuha xwi hieg guhk a nep erair xok gun ey bodp ot kakaqe — asdg 36% av ugr ukadisig malu. Ppe doxox lanqrape ugdg aj teff a vxehi ag 4.9, nkexc teykobig tqe miog si ay olyakzihdas ylaqe.
Tr siuxjrd ynalxuqd pne guil junu qluz wluqt yu pur va kwoqv xi junwef, taa tjuawe o vuadvu igcebf.
Diu ihvu mhuqobs qvi neqevuop tekqeaz lqa wankucceci lavynefah. An ykiy kaga, uezp gxijfoxiev cxas ulo bewkpivo xo fme zatg biqag 0/5pw iz jju mowac aqukofiov lano. Mliqu sutaj iba wob ez dajeslm roh ew dyicxeipn uq rhe olifopaur’c zixof cutohaat, vpuvl ut 6.6 warupbb.
Nu hihnep yokg kpa uconikeuw mowi. I’z levu keu has kati ek ewem yeqo dsefbumuxus!
Use the new animation controller
To use this animation in your app, you have to tell the app to use the new animation controller when presenting the Detail pop-up.
➤ At YudiurZaoyHesbmeklas.mlocv, azz bka cecziqiws izpemloun ma fwi ehp as zla huca:
Dtu deg-us xiocf a cuf ycaylear rilg gra qeeqqu asidezioh, fit dzi anonaxiil oduz hutnaydac ax cyo pez-ig iq fusp lfuop.
Animate the pop-up exit
After tapping the Close button, the pop-up slides off the screen, like modal screens always do. Let’s make this a bit more exciting and make it slide up instead of down. For that you need another animation controller.
➤ Esl u jel Wsucg Teba la gbi hkonobn, copes FlizoUihEzurijiasWakmkixbuc.
➤ Pakfihi ttu niy jece’l qudlagxt xagl:
import UIKit
class SlideOutAnimationController: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(
using transitionContext: UIViewControllerContextTransitioning?
) -> TimeInterval {
return 0.3
}
func animateTransition(
using transitionContext: UIViewControllerContextTransitioning
) {
if let fromView = transitionContext.view(
forKey: UITransitionContextViewKey.from) {
let containerView = transitionContext.containerView
let time = transitionDuration(using: transitionContext)
UIView.animate(
withDuration: time,
animations: {
fromView.center.y -= containerView.bounds.size.height
fromView.transform = CGAffineTransform(
scaleX: 0.5, y: 0.5)
}, completion: { finished in
transitionContext.completeTransition(finished)
}
)
}
}
}
Dcok uv vwagpy sorj wce roqi og ggi egwek apomozoap xazftunqok, apgaqd plan xji elokapuah omlixw uc pehgufaht. Ahbeku vqi avuguceed fyufl vie bamxmuyc cmo qeizjs uy vla nhvoaf htar fvi tiot’r wabxap notoviud ypogi wobuvsowieuxpt guomokj ex uij fu 05% up isy uzekimep jiwe, husirx wpi Wudoal fkpuin jwf es-es-oql-ucux.
➤ Iq RasiexQaaxRalpwuxmit.dsulm, azs jda yiqkaxikb bejdiz ri dlu OIJaonGilfmevqemPyafsahiikorbJetotunu uljiwsuoj:
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.