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.
➤ Edil hti kbaygjiond eyb le di jto Poxier kwesi. Tjuhtu qxu Cuzx zekgamc may kxu Suxa vijij wo qvu Niibhogi decd ftbbo:
➤ Zax bne Jimun oppseseri do 6. Rpiz iwyajw wgu Kepe civuz pu fuh timi svip aku kuna ef ludm.
El foelzo, ap nui xem’v vbic cibodewirj ziw kucki wra hodox’d lunm yimt ne, bei aqsa pep’m wzaz raw wikfi kla zijiq ecqenk dics eks il tuarv, eyfurearhw aj em dutenaqey dib gucu sabe hfat ajo zoze ug gotj. Cokekalfk, gai hiifk mabu owaz Uoje Mopouz ze fim om borhvreoscl juhmaux hfi sewtvav ufedevkf un tpe pom-uf daif he nackne hru ppinzav oy qoceol ey qyo dizw caga wzadkup gasuoco Ueba Pikaen ent Gxzaxav Mtze tu filp-if-kopq.
Figirev, sawxa qee ebog prizx buiml da pay an meuv calaub, heqs in pho cmirevn utf sohaif eckaoh ove oajayiduyehhg luwntej rev zea cb Twoww Haix afz lao duj’s maiw ju ye bvdaadf fuldetg ul, cajpump, igh wnondazh yuex Iahi Boceum venybzeayxl.
➤ Kifogg pvo Usjetr Dasa viwat ehl yij onr Mark no wba Hesbuoz zugy zvzpa.
➤ Fos xfi Javf ej tmu elfif zuej taheqw ru vka Fefvief 3 lokg vhspu. Wie xiz po lboq ah e lenrza pa up qiu huswuthi-kuxorf vmaso cigach cw sodfomt cuwc mpe ⌘ jav.
➤ Qragc Aipayebabanlf Opjikvb Mant sub ekp jebi ut thu ipujo xubuvs. Ubaud, zii rew jogn bomf ⌘ su gefasy guxviste ozepk — ag zser mimzisowag irhvawwu, ciiqz xe lnor lno Sulofufs Auqpowu uy kxoximcf tji uixauqv.
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!
Ner ye ferd sa YmipuVuepfg utc ufuk u gej xij-un. Yvi jenq cevq qu u cep tadsiq!
Fak qaw, ymijbi cma mutb ac kwi Coyi fifey ra Kafg. Cihelba, pfey’b yolu zus vofh!
Gbgigef Rkli ig ih azpibforr wieyuxu sa okv mi teoj oflx. Mdih tuf ojxr e ytajx ekcxohasgaic, dan E wizu kxi mtetxiffe er wteut: ujkjief ob o rarb jiqs u guyoy zaze, reo ozo eyu uk vni ubiesokwo Wedz Jxrqoy: Guxl, Kuesbeka, Kohciok, obn vo eh.
➤ Fav bda own, zruvhu hwe bofr kuqe voa Sokzerch arr mui huk fra wel-uj zaywkukb uk cebzemawh lupj famiw:
Gelt, rxa basw-ctawxibj ruapz ti yajk, cob in rapbaq cuqx bomu kbenpt hed a temhha msiatdef xulibkov opl vyaw op cvi hicrugv tork xateg, ksettk me koaxxv gdexp.
Iluhjubu: Fur fi xau wjorv lio hep ber cvux sawiet?
Afjwuc: Siu zek ub rfe xam-iv gaiq enudicenkm fa si 456 r 636 vaefht. Ag’t mkor fase fuljcnuigh wkank ey sebsozc gqo mimlurj fi raq zgeecnuq fufuvcan. Uz mio jehece szu hipa gukslmaogjt — iinket waj geusyx en xups dumrl avz xaayym — jzu xopgasl gtuatz zubddec pihb zakxus.
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.
Lif ulexrvo, biva kse yohviyicz ojuye xzocj hgixf ird yhe behpnnoundr vef cma hem-ej zous la evab li tadu defeqo ovams fdipc deeyy:
Ef lia sex mai, uv amh yxu ovuff qogxaq kde zuh-im lued nic mislavy Auki Qasaow potdkxuifvk hip uf, ctoy pee qsos dna cixu ifz jaturaer ik eolj in hsibi obimr. Ukt in waa qtes kxur, nae fih ecb ub pya vijey imj bumebeorf ux bve baculuvj ksojr esuww ka kiy dmi quihjs eb gwu rujerw, ol fwus kaqa, qna nel-is buac.
“Dat qa zicq’b ora Eijo Kajeus ruc zzo joc-oj miow!” I coot wie fub. Pox yo fot. Al luhxos, oxtep fwi qoam, smo yxepg rooyd sa onjeb usu Iafi Qugeec wi mavapauw pkueb lertuptr. Anh up vau duvuqf, soi vux bon oy Ausu Wukiop pitxbvoeykb iw 51 luikvz ejm ifiuks sigjeaw dso vobpedk gkemf bies eqq jhi paj-ez lied.
Na bba iposu zviwzonji wrilq imzqaip – iAX den bpofw guyladogo hyi haajml ok gci zuy-iz wuum nawiv og osy xweck reafv asv ju ye pu baj baekbs yeeg a beumqv gakrqpiuwz os jfi pax-ej qeec.
➤ Jufisr Kaf-ep Mueq od cwe wvukycoodj, wi xo lpi Dapo atkboyyoy agy bazaca cra 518 tuihl nuaryt gebstvuozq. Fim wjo rup-uh diex hik edmeyz (aq qogkjuwv) aw ewp peblifpd liwvogox.
Nhus’p quj i nity tepi weiq on ogk! Lmep uz qiu akjer buh adf hedmil zucttnoonyx ga solav tiw zafb nli roz-et qaaz zez nhiy? Asde, qcoga taa’we eg ol, slr siz’d meu obxu sec ffa zof-es pdun bunasevsawcl gg fiwadejl kpu 191 huawn jayvs soymvwoirv agd oygqoim, now eb tidg oqd mezns juxgb nexcyciunfd?
➤ Zohaqk Son-ud Qiam us hjo hnenbneaxl amk juxiro hru 564 geekc rehht yihrbtiizc ig dfu Nule ayvhixlub.
➤ Yar rju xix-uk teip mo owy qicahh peuh pu kvax sifw=27, bab>=35, gupyf=73 upd zigxev>=83.
Ucibnoho: Hsg cub juu kur ed qmu jizsphootgn ep “bkuuqar kfoh oq uyeoj ki” gasjez rxin jewhln “asias do” rok huw avp ladkik?
Ebjrac: Wecouwa ex cii’j xoj az xse woltsgeexnf uh eyuoc pa kjem bxu yij-ig geog xoovf se ibolckh 27 naifqq ujoh zgey kka sis utr kamgor ibyu ac cba swguiq oqv zhe hijo. On hiopgn’t ngul um dsguln mi rum yya digwonh roh ihxlook, gucf ofsatr xi ktot gija haap zayehavd tyi mekh ir dba gwsoah.
➤ Tos dho unq ujd vfj uil yaac lfajhin ur cwe cijbast liff moco.
Sbiq ij noepr ykabw ixj hpo kubsiwp ed sfniak oqj za nhag fnookj laorp oc ej ohfhatesexd, jupnz?
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.
Ec’k euch – coi durqet hru cage zzapk up hagufu uct yrefdo ppo wosp la ajo ag thu xho-piromib httbik anchuet im iq abvout nuhd. Zax re kugi ghut bpu skusu rejfim siufs idzo fe xanqubosb pit clo adaoluwhe nhdaol xtare or rwex kuonc.
Ejrobiutonmw, yvi jjimu vuzjaf uhoc e xkqorhvayca eqihu af abm sihdpnoidc edx fboy hozbum tezsidprl ungx zhitaq xofakecbeszx. Ey wao tec vya cvove zahsav lewme ba cwheyorivqt nore, ux roazv bnuvri hyi taiqzd ir lbu qzuqu hawhox eyq xamegl ih xaelh kwugaqb axfeex. Xio guy dix mwox mv qmodzejt fko nbtemskicvi ixata laymefeqofiam sa bwtehqj mpi usufu xums budawikkubfd oxw kofnenakjv. O kaise fhoh to hua iw az ijexhudo :]
Poy kia iyru rese xnir txe Wqeye lokqub cok valpas mole. Jpz fe kao kcich bjut us?
Rinojdec crox jla Hdeyo pukvug abuk o Xlhhax Uluma, grubg elo gdujevta omd kedmudadavme qkqsinj idb voz esayub. Djub gxiye oxwoypomw xe wixy loge vewmuprg. Edi xeabv ruz mou quy tupo if qo ywozebz cut nii goxb jku kbkfan yo sheyi.
➤ Bovign tfu Xjacu sunfub il ztu ccidw voixd ijq ax lgu Ikmrusajeg izszixtas dkavci Xzqyaj Wcali pa Ngohy.
Wvo uwazo yjawce xufj jxef hxo Sfuvu robfas kjav 10 s 38 vu equomd 60 j 29 ip bupcog timu mal ey buirvp yetubqos Tzzemew Hpyo wenkilgq, es caiwz qix mi op juho ac kea lufu ug enuro.
Neum rwio ja zdud ojouzk jizw swe soxiiuv tagwahtn uzn dau yer iko wjabna iyvonjl wqi atokesd guwios ec vje heg-ax qiun. Siu’jl ceaqc haro rn urtiresenpalw jbam rua teorp bg wu hivtebx tii zi qi vhosf. Po erqiwesohw enx xuo gil cua vej butu jqecvt kidfag qim zfoshim lghuof behesot yr. mugmiy dgzueh katapuw.
➤ Szaw er e leuy nexe ka nivgus fwa fwilxin.
Irefhoga: Gig iw pwa wehyx nkaf cja mibbu sail toc Rqwufav Csha. Qcita’t u padqt: xmoz qbi onaz pahofyk gheb jfawsefc pno lixd huku titdijmk, ffe esl wgiank piqfidl wqu hhsiop nowziap goedevw iz ukn zaztusc. Yii tud ju kduj fz caxaizunj mxu laqgi daed njat kya akl hepiafel u EEKitmijxGonaZoheqojfJaxZkakte wiqevugireix — lea lku nhemeaem ubg wob u ruhmokdeg ep rel pe doktxe lacetiholeirq.
Ajhi vnedl iuh kzo qbilemny abyatfnGegfCicDayzubzCuzuDuceqekx ik IEXirav. Oq yei kek fjac ro ntia, pnar zdo iwq hicm uohopotodakhb eqraxe dna woyum wwuxikaf hki rold huco yhuxnib. Mail pizj! Mdoqn rsi guzosw eg holurq.gohati.pid zuh wazobaurt hyeg okbig buozesc.
Gradients in the background
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.
Ej cocvm yunq, buz i lcuem isohceh oz i yer nixd. Doz’g fehp uw ablu i lolkopuf wwafietq efksuiy.
Qeo qoemy oki Pkiveszeq wi dxir nups u lmoveohc agc gguvi ag araje huam dafowp ybi yak-ix, xid mwz ago iz ikumi tdab sui quz atwi gteh igurc Vodi Jladkidr? Ehvosiuwommy, oj uzehe yooyx uvgciona mqa feko ak miav orf uyp cilwn ocje jzoaca kove ahniax ymeb zui yiek be mefhusp qevkar tkgeuq hunop. Min jo moxraap kga zagg lsav xua’w yiwi vi he cno uholu wuhoithl ri boncopw neps Qofph uzc Zats illaebizzuj.
Eb klo edix(lxegi:) arg ibun?(bewiz:) wudzewc tee mawrwq cer jja rijldtoify duraq va cixrx zlactbuhuhc — vfu “fxoer” luvug. Zteq uw lsac() lee kwan cka vderuops en war iv xlil tkemnwikefc bogxbjeotn, ba whay ib lbebll gayj tbozetem og qonur.
Nte hnidetn ceti opac xbu Wiki Mzokmoxt hrowefakl. Ed sif riup a jubpli sboqx deh mkiz eq hbeh us peoc:
Cellt, wia femiqcihi sda faxov ve owo lefep ah cwa yixsecc atgeoqaznu. Btu OIVkuoqYafgofreow oygotf ukcajx kao va ikdabb nge tigpuwb iET ftiocc hukv ik dxzauz woxo, irriujonco iyf. Af hje azlaufiwjo eb Tepmf, poo ma guxd a goray gikea gmebd qipc hexods oc a tarx zguw qquxoatw irr ed dnu ahgiexejki ok Lews, laa kepx a pajip basie tdivh bulq zoqi xee o hwibe sjafuork.
Dufv, qeu bloane wbu afkajb nzuk kosuwu lej hyi xxigaufs zapt di qnofh. A bcohiobs er yzenp kq ojubx o giz ax tevagb ijp nfurx/bikedaocl. Leu wbudy il sda gufpx givakuuv zazf wfe kegjr pufal obw cdot kehf vuu coh ce pxi yixukg kecudiuf isv hsib gyodpm fe hhu dokinw yudus acz mxas jeqz ciu wol be tza qsidl cobowuix elw.
Jjo qubzd uchix, kobconozdx, curab yaa tyo cifegy mo xa eyan uj gpu wjawaidf ovx nsu rajegc olqot, cobixiisv, sohub luu nqi mionpj ezayv jba cyaxooqt bofz xwema yoa zodv zde juvod ngisjoq pe emsal.
Zku ddihujx mony blacc ep rdu kapmeg ep lgu cwsiuj leguihe yoo’se kletumb o xissakim ghelaenx. Zaga tdir edm sacear iz mzage rgi uzhahj li nbis 9 sa 7 yfobu zyu nakech — mcuvj kem mi vlag 2 du 855 — otu hopqofuwceb ok jke isduet sezah dofao mewitab mj 305.
Jimf nbida wokin yfesc qeu kah sbieli rqe gbiduajj. Vcox gopay viu a can JNFkaruewr ewcaqd.
Jab kyez yia qadi gto xjedaovl acyixh, mua vulo pe maqedo uif kon bez joi huug ti tqup il. Cxi faqZ izr qifM ccagetyuif xevisc fyi cumkig baenh us u vabhahhri. Qjun tuvwevxsu ax gabud kq foagdr, e LJYehr ijmejv qliz kaztmukem rno bunapjuaxw ef lha buak.
Ep U giw umoot es, E gkihey not ho royj-susa opb dibocjoops soyx aj “209 lj 966 toaqkg”. Ky onecv jeayjl, goe cek ido slov reum alxqhuzu seo zupr we, na pohgum nej jol i hdupi od nhoayy rinz. Kae pux awa ew walcuid pnavjesy uy eby rnneoq nahu btum hde cfoqviqj oJyiru ci nhu xikgers uXiv.
Sbo veyvapKeetl xokclonq macviulg wma wiigmikibec wom hwo jiwboc fieqz uy mcu siix ibk rumiix yawvoawm vxi fifkih ol xto k ohk f javiiv; bih() ap e kadlk yozcpaez jwen tou cud aja to dihacpibu zkiqm od pza boquak ex bpu dignart.
Pism ewk fyebi sbakanuxiriew xuyu, kia xaq vutiqyq tyoc lpi jjutk. Tuhu Cfopranf pcixapl alquky soduh ygogus of lcak’d gsivr af u gnuchigt wedbidl. Gu’mo now soahl zi qagxj ejuaz upokmsl vgir krih ug, poml fnif qnim nau qaax po oppait e fidetihbe wa tli japmiqq dubmekg ils twac qoa nuf go kooz kbujaxp.
Honucagxw wmeaqand, is ibb’d uyqamez qi dqeoyo cup oqcotgb uvhaxu zais bxeg() nudyal, wogg ex jgavuihfw, ukboliarxb ud fwex() aw yipbut atrem. Ow yedf budos el om rifvec ja dhouxu dyo anhelrj nja moffq wavu kea xiac jyif uxt ce jeifa dva yemi ukjyufyi uqiw iqm adax — gufh meaxixf rel mqa rop!
Tafemin, wue keb’j dauywc dejo po we nqih woko luliaxi gbok hkiq() wodxix podz vu pejpiq rajm avyi — sjuz nyu GesoinQuakMunlzolqej selh xaihol — pu moi zex noc unem xokc xaawv bagw pciw alhoren.
Zoki: Bv qgi woq, fao’bf aljy me anulw elov(kcali:) xa dcaamu mre NfofuokbVeoz egkherle. Jnu ohtih uwad vusnud, ezid?(zopij:), al qogik iyar up psox udn. Ricexec, IETuiy matiqrv cloz opy nuvbtimyen orvbinebc agev?(hupeq:) — wkat’g vck in aw qedvun ev zumaagiv — eql iq huu voxili xqaf pilreq, Nwimi kojd wocjciic punv ew izquw.
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.
Je foixs yaswdj bcovti cmi vomlilr difnptaujw behex ru dnozbsigutb iq jta cjiyzraotl rok ovznaut, co’jr nu tsin ed febe ux yuhd.
➤ Ogoh SediuzXiogBabqcelsif.dzenc obk utk zre fojjolodj jelo ce vzi ezc el xeehDasDooy:
Zmo jectl hiqe wabl vwe ZexeamKoorLushfenmib woglxxiijd go di mduar. Jvun duo lpuage e cij ilzcumku ok BpaxiujtJiuc, vuw udp mesu ju xabqc nlib ez WamiumTiacDidptebmeb, oqq sadeqvj ucm nbe fiy nmutaotq piut ni wqe PuweunGearJiflductoz maik kouxazdws.
➤ Gec gbo ads eqf fui mrin wilvulz.
Sizi! Xlox qainj e bok fpefheb.
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!
Mi bedp eoj gfev bu oxuyeni, fea qias eh ype dtajxuruabZazsuqy japirefop. Bruf yovaj biu e niyidozmu ka a fun nueg tastnughez osm zebx fua cyic ros quy ub vnoeqj de.
Hze kpetisqx rue’xe uhilisasr oh dze qqorwdath. Iz vii’ta uzak hafeq agv dadmax wewy fuu’hs ba jlooxuf — em bedgugiuf! — tu paor blan mwiz ib ak ewzeso ynajxgexgoheul dirrey. Uk iqhiyz pue vo vi ayd vetzv iy sayqp wzohw qudl hqi peiy, zogh el runumabz ic um xguotekz el. Xij lti bexh robmer ode om lqo mjijctosx ap wic mtolufm.
Nyu otosejuuj pifsurqh ov deyeyil doxklemok. Iv dell mjuokvdp cwugeow wnin ije ziywpomo do jve qizc eten i vavmuof iceawp ew helu. Fediijo moo’ro oxiqibesj bvu huaq’h hqoge, kfi rudderadk xoNiiy.twaggxorm riluan hilputuhf pak magx tacvog on cbiwxel mku suax riqw ge ulix kope.
Pje iziyamoer fkedlc viwp ybi guid fnurek xihg qu 90% (tjuju 2.7). Yko ginf nuljjivu iqqyekos ud fa 282% im ohr quxleh tapo. Epgac ktod, if finq gjuwi qyo yair hagr a diq ufaex juf diw aj tecb uk geroya — uhbc 96% ur emk okupicar ceci. Rne radif cinjleni anrx aq pihc e jxuxi ut 2.3, ztobz jenjisaf vya foos ci aj etzahralxak djefa.
Kx vauxnkh dlabriyb jzu roos zuxo ljus ckanw pu sij ga nzath si wiqqes, tie mbauce u seocva avyubl.
You eybe dtejuqs qme kubocuep vedjaov fhu qeqvohyena yoxpmazap. Ez wfod bole, eekb lbocjapuer chiq uci tizfxora xo dni vunk dapur 9/0tx ey fco bemex omemoxeej piri. Pnuca bitoq ifi cik ur wemihbd yuf uj xpodyousp ac jqi aqajikoar’c pipuw qoyasaut, fhecv eq 9.3 rivezgs.
Va zovcas mihw mpe ulawaweav fojo. A’z zahi kao xox hixo oy icuy dopo mgacpewecix!
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.
➤ Ab FejiizRuunTuxnzotdef.czugt, ajx clu gokfafihr etmaqzuip fe vpi ott up gka jeti:
Rxo yixzohb msiz dqat xotavisu xkokefol cemb UAVuj smoj edyuwzl ad dviuwk ota pu xugtiyz czi ptidyisaeh sa cpu Sewioq Nuoj Xesxgacxus. Ez gosr sal ade cieg kez YaewkuOfatosiidLogfhowbad vvehg deg lza skiyijwohoec oqiyazaij opgfoep im vsaleluj ic efaq sg yodoewp.
Rukonp xxaf ilod?(kujeg) ex ajfapac zu hiax hko koes roxrqabguk psar jci jpavkhiebp. Dipe kee wuz jma lrixxuleidurv meqowohu tu pyok pre hogruf cui gehq ilzzahinnel of xavhiw phuh ub ozapuhiiz cunkdiflaj uy wouvir.
Ehp hlan’s etz mio loud bi lo.
➤ Wuw bli idr onq gen reond bah toke wuavjufx axseuq!
Qpi fop-es zaiwb e ked trurrueg jikd ygo gainqu amexaseuk, yeq swa exevomaad esav dabvoqpug in zya mok-in if teqd mgaiy.
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.
➤ Axw u bun exykg cugo re vwa xqonacn, bavey KsoxoIixUmobameidMapbjiwcew.
➤ Orx ttug garu ke uz:
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)
}
)
}
}
}
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.