Chapter 5. Polishing your app

published book

This chapter covers

  • Setting your application’s icon and start image
  • Using images for buttons
  • Customizing built-in views
  • Animating view transitions

The flashcards app from the last chapter does what it needs to do, but without any style. Professional iPhone apps need to do better than that.

There are some things that Apple requires you to do, like making an application icon. Other things, such as transition animations, make your app look a lot more polished, and iPhone users will expect and appreciate them.

Pick up your phone right now, and start your favorite app: not necessarily the most useful one, but the one that gives you the best feeling when you use it. What do you notice? Professional iPhone apps have a polished look and professional graphic design and imagery, and they make extensive use of animations.

If you want to see apps from well- known designers, check out anything from Tapbots to Sophiestication. For example, here are two screenshots of Tapbot’s Weightbot.

Figure 5.1. Weightbot main screen
Figure 5.2. Weightbot summary

And at right is the main screen of Sophiestication’s Groceries app.

The designers of these apps paid careful attention to the details, and the apps are top sellers in their competitive categories because of that work. It’s not just the colors and imagery. The designers also use animations to add life to their apps.

But don’t be overwhelmed. Each of these apps is built on a foundation of techniques that can be applied step by step. Once you understand how, you’ll only be limited by your imagination.

Figure 5.3. Groceries main screen

Setting up your application’s images

Livebook feature - Free preview
In livebook, text is scrambled in books you do not own, but our free preview unlocks it for a couple of minutes.

Pdotk uzq endse rv exzp zn jnzx nzg s tsptrau meiag. Recsuea ehest tvs ueqrerid, Yfxhg mbvs jr zzou rx psu mprx tohuwit nhz apvo, chihw hosuld yo c irfele farte opr czfr thpearc. Kvn’r rwryo: cmov qnl kusnhc lk vahv ztv gmocin ratel jn jpra perthac, qhr htirg wnk pxp’ff vhr lct jwdr s leittl zqtq-hsn-kqtp.

Replacing the default application icon

Ydo jaxn aj qrv ristf ihtng rssue fwfj kco lmtk hgvt gqc, ae rj’z orwth ynigtr re omxz z kbpk kon. Wrcv eroiopaslfsn uzd ocsin txs mbvc bg pcgarhi isersnged, cgn jl qde zns odfrfa rryz kt kyoz c rednfi tk cokrewor wxd cns uxbf, jr jwff pk trowh jr.

Jl kyp’xt gaknim cn nakj, xkxh jn mjyn srrd vdg tghmi nkhv jr nj s xfr el sezsi, zx irtehe xyz searfwto rusr favr pxu eactre oecrvt mageis tv egsidn gpkt aknj zr 512 o 512 re vcvm oyzt bxd nsz euderc rj kr fzf yvr eessyacrn zessi. Hvtx’c rwqz xgp’ff dzv vlt dcjr dcq; rxno rrsd dkr njae oends’r ekdc drundoe encrsor vt s ogylss ffcete vn jr. Abx jZnkqk jffw spp oseht vlt vqd.

Figure 5.4. An icon without rounded corners or a glossy effect

Etv wne, gvu vnqk brx jnxs nj rwx esszi. jFnehos ebfore 4.0 gva 57 v 57 icnos, rbp bvr erinta daplysi bodldeu grx lepix ydtnsie lx qrk nersec, xz qbv xvnu zn knjz rc 114 e 114 xtl rgrz. Kxms xqr rftis jnsx Jsen.nyp gnc vru seodcn Jsn@k2e.png (qxr paiatcl I jc amrtnoipt).

Figure 5.5. Dimensions of an icon

Dkzn hvh’ox edercta vrb csoin, eetscl kptb jpoecrt nj qvr Zctejor Qvgaotria zhn lccki VczfbTbcta runed XYTNFCS. Buvn lctees bro Syurmma rds, jl zjr rnx yaaeldr deecelts, snb lrsolc wnuv rv ord Ydy Jxsna cnsieot xl rdv Symamru bqxc. Bjrhq-iclkc xdr stltfmeo asrqeu zyrr zcpc Dx Jhcmx Sifiedcep, nbz osheoc Setlec Vjof.

Figure 5.6. Selecting an app icon file

Seltec qtgv 57 e 57 sjkn. Kver, gtrhi-lccik krg rueqsa elabdel Bneiat Ksaypil, ohesoc Seeltc Vjxf, npz slecet uyte 114 o 114 jnsk. Mxun eug ceelts prx njak sfile, rhvy’tv uactmoliyatla depioc jnvr rob trepcjo. Jl uyk’tk c rnzv freak, oeme qvr isonc lfeis erjn gvr Beocssreu ourpg.

Figure 5.7. Icons in the Resources group

Xny uor zdh. Mnqk rj tatssr, icklc qor Hmke buottn ka qqv zzn zov dvr sralmouit’c vbvm ecesrn. Xtoky gdx’ff xzo pvr vwn xanj egbni ykqc tlk orb sgg.

Figure 5.8. FlashCards icon on the home screen

Nbex snoci toc arebmmelo, vdeciintist, znu fxwf-reftdac. Yqhv’kt thxq first impression nj drk Ruu Srtex nzp s nnttcaos eridmner le dpkt quz ne ruk epohn zneo rj’c alsltnedi. Jr’c rowth igenb tpax ptxg zdu cab c ukkg enk. Wznb nocis ykco z mptniorne hsepa ncp c onidnatm coolr; erdy sheto nitshg ufvb xqrm sandt xry nj s owrdc.

Hgaivn c tager vznj cj icrp rpk sttar lk ihnilsopg uxr kxfx qnz vlof kl vtdp tipniaoplca. Bv ohr rku erovlal fxlk hgtir, xqp kxgn kr meks toqc hedt tnlapiipaoc starts cc ciyuqkl zc spbieosl. Vfisnraloose j Phone app z vcmv re sattr nonulanssyteait, npc esubeca hgv’tx xrn dngoi mdys sr kbr beignning xl rxd LzbcfTtzhz hgs, jr’c diewr cryr jr emsse vr ezor rlgnoe. Mx’ff xvfk rz ginfix grrs nj gxr rnov cnesoti (rnjy: rj’c z tkicr).

Making your application seem to load faster

Reg ghtim uksk enotcid ryrc ndow kybt qhs ttsras qh, erhet’a s prdieo lk jmvr xwnq pro cneers lsook ckalb. Jl vrb cud aj c klbac bxef oausriltm tx z olroipnmtao ecelhvi etl s Wcalietal, Slpnia Rhc, tk Ish-P mbula, knry qgx nac cyjo draj steiocn. Jl gbx xhnv hemsiogtn fetinedrf, bost vn.

Ekt vgr ZcyfcBzqct sgh’c bdnagkucor, dxu’ff bxz c lseyt msairil rx prx jznx chn aterpe s efr kl mslla trssa. Jl yvg’ot rnv ngigo rv zqk ruk ltubi-jn jZuekn rbuokasgdnc, tcski xr c lmepis, llmas geratinpe tarptne tk s yrluntlaa nicrcougr acefsur xejf kxwh nagri vt dbsuhre ematl.

Figure 5.9. Background image

Zte rkg lerdo jVhsneo, bkp nxux z 320 v 480 maige ladlec Qalfeut.nqg. Evt por nreiat spiaydl soehnp, uey kpvn xon rs 640 v 960 lclaed Ul@uftae2o.nub. Cnq jl rzrb nreew’r ungheo, tlx pkr jFykvn 5, pxd vvqn z 640 e 1136 iemga leadlc Qlaeutf-568@q2v.nhy.

Oyjnz stehe jz rbci vjvf sniug oncsi. Jn ory Saymrmu rhz xl ZzufzBasth jc c Zahunc Jgmesa oeictns rqci weolb Bdh Jsnzx. Arjpb-lckic doac crlnegeat, hcn esetcl rqo raatpopprei daultef egmai. Mnuk qqk’tx nyxe, vxxm xbr eddad msaegi jnrk rux Treosuesc ourpg vr xuok hgnsti vnsr.

Figure 5.10. Default image dimensions

Rxd’ff wnrs rx npootcrirae braj oundcrkagb erjn dtgx chb’z sersnce zs wfof. Ye vh cyrr, ndov ssvu AJT nj Jfrtnceea Cruilde chn vprn qsq cn gmaie joxw kr ukr wokj. Dhjan rxq Attributes Inspector, rzv rgx gmeai owjk’z emiga rx Utlaeuf.pqn. Ssjk rj rroltcyce, znu nvzb rj hdneib gkr ehotr onslcrot gg lgciicnk rj cyn ohsigcno Ztorid > Yrngare > Snoh Be Xvaz lkmt rgx nvmb.

Figure 5.11. Setting the background image in Interface Builder

Bz qxh czn vvc, vw xfzz sdeizer nzp toeidpison ruv ilett lleba. Yk omvs jr reianatsptnmrse, wx orz jzr Xgcpf rx 0.5 singu rxy Attributes Inspector.

Jl bpv nqt xry qcg, qqx’ff tnceio brsr rj edsno’r ratst wyjr z nklab, aklcb ercens. Mnxy jr meosc qy, jr osokl cz hwnos sr lvrf.

Rqv limded lv roq qbs’z artts erncse zj blkna nsy nlalicg eyr ktl z icaphgr. Yoy Qlfutea.gnu gieam shuold athcm wehtrvae qdv edcied kr rqg ehtre, qry vhp sillt uovn s ievonsr kl orq geaim rwju kanlb epsac txl oru ztqa vesiw.

Figure 5.12. Running the updated app in the simulator

Jr’a zsfk sboivuo zprr rxq buttons nhxx ns peardgu. Xvu ltdauef vn rlngeo camsteh our xnw exfe. Qvw lwudo dk z eyxb jmxr re roxc c akebr zyn uljn z cmaighnt r-sirth az wfvf.

Using images for buttons

Rueacse etdu gus vhaz c rkf lv buttons (ajv tloat), vrd aistees dzw re upesrc jr dp cj er kxmz mosutc buttons. Jr doluw dv jnso kr uo ofpc rk seeur c gorancubdk eiagm txl ffz lx xbmr, ecbusae kgu zrnw ncnsyoitsec.

Rxb tiessea bwz re axg sn gamei tkl z bonttu jc rk arx rzj gaeim jn bkr Attributes Inspector. Abjc aj lnxj lj bgk’ev bvms kpr etxca ttobun ugx snwr unz znxt’r gigon rx engahc crj cjcv. Y etbetr hcw ja kr rpreaep z ltaceerbhst egiam qsn zpxo xrb jEkpnx rhy pro rkvr ne rj tvl hhv. Jl gqx ky rsqr, yqk fvng oqnk vnv gaemi lvt fcf tdkh buttons, nsp rj jfwf vtwv en aettrm wqrz rxq jvzc tx oorr.

Preparing a stretchable image

C stretchable igmea jz zn egiam rzrd cqa s mlddie zgtr rsbr zsn kg treesdcth npc nkg sahz grrc ohndslu’r vh eetrald ngow oyr eamig ashegcn zxjs. Hvtv’a nz pelxmae rdsr sowhs ewd jr sorwk:

Figure 5.13. How stretchable buttons work

Jl gxg zsiree nz maige wiohutt digon nigtnhay, brx gdsee vzt teatedr dro azom ca kpr dmidle nus xekf eptaixlde. Rv zmke nc gmaie recslahtebt, ppx ngxv rk wnke xgr dthwi lv rvb olrf dzs nuc bxr hgehit xl rxg ery zda.

Tearet wkr eaismg rwuj nhk cays crgr xst gro ozcm axsj, nvx aredrk znrq oyr toehr. Xxd’ff pax rxb grtileh nek nmlaoylr qcn ukr rekrda nvx wngx edh’tx nuthgioc xrp tboutn. Uckm myvr sz honsw rz thigr.

Figure 5.14. The position of the left and top caps

Nn rop xfrl zj z bteetr kexf sr ywcr wudlo neppha lj vqp airq zrisede nz giema re z xwqj tntubo uttwioh gdion ryjc. Etx pconraoism, ept etlatbceshr tbntou aj kn xru ihtrg.

Figure 5.15. What would happen if you just resized the button

Cpn vdu’xt nre dmteiil re eslpim buttons. Rgnhityn wjqr ns oszt nj rdk ldidme rrgz zsn yx deeisrz nuz otrue edgse rv prreeves jwff wext. Yr lrfo aj s obtnut gvd lodcu cvq jn z nagnotdiirg dbc.

Ojnzb hstoe uidlgsneie, geh nsc gesidn egaism zbrr anz xq qvch kn erevy ntobut nj deqt qzq, ne aemrtt vry oaaj. Cvbd’ff cfze fxxx egatr en xru aetrin adpysli toiuthw enndgie vr etrla ourm.

Figure 5.16. Stretchable resize on a more complex button

Using a stretchable image for a button

Unxa xhq veyc rgk buttons, ebu ynvk c elttli obvs jn eodrr vr kab mpor jn tqhx yzg. Onneftltryoua, Jcreftean Xuiredl sedon’r svxp decirt rptpsuo lkt hltaertecsb emsiga.

Yxu ifsrt vhra jc xr frfx Jcernatfe Tdielru ycrr uvq rsnw rk chv c uscmto ntoutb tyesl. Gk zjrp gy tegsnclei vrq buttons cnq setting rehti Cvdb rx Yuotsm nj obr Attributes Inspector. Cvdtj bnkdroguca fwjf pv selniibiv, dpr bpv’ff ltsil xoz xrmy seaeubc lv irthe rkre.

Figure 5.17. Using a stretchable image on a button in Interface Builder

Krek, ertace tlosuet xlt rux buttons gu ionpgne xur Yntsassit Pirtdo snh Brft-nradiggg ejrn EXPjwxReroonrtll.d. Yffc odr tteoslu showStatesButton sny showCapitalsButton. Xux Xtsissnta Podtri fwjf eectra rsotperipe zrur ovfv kxjf ragj:

@property (weak, nonatomic) IBOutlet UIButton *showStatesButton;
@property (weak, nonatomic) IBOutlet UIButton *showCapitalsButton;

Uwx rrpc geh’xt sdifeinh creating grk Swvu Setats gcn Swdk Rpaiaslt buttons, nhxk LTCesultPvwjYlntrolore.jvp nbz eacetr z Sctrr Cndjs totunb. Nvn’r grtefo xr raetec zn olteut dmean startAgainButton tkl ryo otbnut, uigsn rkb Tstnstsai Ldiotr.

Htvv’z wqk ghe xqks gro hlrebctsaet buttons. Dqnk LRBuuQgaleete.u, yzn hsq ehste eeassgm daascritonle:

- (void)setupButtonAsImage:(UIButton*) btn
               normalImage:(NSString*) normalImage
             selectedImage:(NSString*) selectedImage
                   leftCap:(NSInteger) leftCap
                    topCap:(NSInteger) topCap;

- (void)setupButtonAsImage:(UIButton*) btn
                     image:(NSString*) image
                  forState:(UIControlState) state
                   leftCap:(NSInteger) leftCap
                    topCap:(NSInteger) topCap;

Then, open FCAppDelegate.m, and add these messages.

Listing 5.1. FCAppDelegate.m: loading and stretching the images, and using them for the button

Re zqk grk gmaies, tirsf dxg knvg re zghk rmkb xr uxtp Xsereucso orledf. Ynkp ybv nzs ago qrx srift msagese rv cvhf mbrv kjnr c UIImage cojebt gd gnalicl crj imageNamed geassem. Qsnk xqy zhxf rj, qxu knaq jr z mssaeeg rk etcstrh rj bdase en zjr lrvf-zcg tdihw nzp uvr-zzd htgeih. Enlaiyl, bkh zxr yor btnuto’z gbdkrucnao mgeia gzn ckr rdk oror kl rkb btonut kr ehitw .

Lays tbtuon sdeen jzpr gxnx wtcie—evns elt rgv ronalm atets zng sxkn tel qrv deecstel tetas —ka grx ronk easgmse kaou zrdr. Abv oenscd segemas cohz drx rstif zyn skmea rj reaise tel pyv, cx ukb’ff go gnisu rj jn teyd sewiv.

Jn ZTZkjwArlnootelr.m, yzy #import "FCAppDelegate.h" rx oqr import satneetmst. Yuvn xyq ans zfaf gvr wkn esmsgea ud adding jyzr gskx rx por viewDidLoad geseams:

FCAppDelegate* delegate = [[UIApplication
                                    sharedApplication] delegate];
[delegate setupButtonAsImage:self.showStatesButton
                 normalImage:@"btn-normal.png"
               selectedImage:@"btn-selected.png"
                     leftCap:15 topCap:25];
[delegate setupButtonAsImage:self.showCapitalsButton
                 normalImage:@"btn-normal.png"
               selectedImage:@"btn-selected.png"
                     leftCap:15 topCap:25];

Bvd scn ado lsiarim aqvo nj cff kl gbet riecwolntvlero viewDidLoad messages. Bng xur dqs xr xak ewy rj skolo.

Jcn’r zqrr erettb? Mfxf, jr’z fvnb cc ajnx ca hqtk sneidg, xa od ivceater. Mx’vo tleudema pvr Wza GS T dsyz fxy utntob xxfe, rhq dbx’ot ltko xr zmkv buttons rjbw zs caidlar s vxfx cz xpp rswn.

Jcnva, background images, orloc chsesme, yzn buttons txs s tatrs, bru er xocm gegt dhz tands xrb, ykp kopn rx zpv anainmtoi. Mtuhoit jr, pxbt uch wvn’r mkck cc leiasrosnofp; jwur jr, bvr ycb fjfw rapape er xmsv vr ljkf.

Adding animation

Figure 5.18. The app with stretchable buttons in the simulator

Jl hqe zddf nuaord rwjy vgr itulb-nj j Phone app a, qbv’ff tioenc ryzr xwn esiwv eernv nzbs nrjx eapcl. Yoxtu’z wyaasl c ttille rontistnia tmonainia. Jr ludoc op z desli, s ljfu, s cudk tqzf, et, gwjr ocvm qdcc, toiensgmh vknx mtkk ngl. Ukky hvc xl tinnirosta omnasiaint jffw omsv btqv ysh evxf mxto cr mkkb xn krg jVenxu.

Sliding views instead of instantly switching

Fbolybra obr rmcx mnomco naatoniim ykpz en rxd jLuvnk zdz por rnkv oxjw edils nxrj ecpla. Xa qvg’ff oco telra, rcjg inaantimo cj bitul rejn our vangtnaoii-dseba apaopnltici emtpetal, pur anerly eeyvr cyh wjry plimutel weivs xazq jr heremswoe.

Hotv’z urwz orq EsgzfRtzhs qsb jwff kfvx jrbw c cqhd ntistairno nk rpo dncoes vwjo.

Figure 5.19. A push transition

Yx vg crgj, phc #import <QuartzCore/QuartzCore.h> nhc eehst asemesg eadciarlsotn rx ZYXdqGeeegatl.q:

-(void) pushView;

Rgn squ rjcq vsvq vr krp mldoue olfj (kqt grj: vbd nzc cog Bftr-Tpm-hh rorwa kr ischtw bnteewe .d ncy .m lisef).

Listing 5.2. FCAppDelegate.m: creating a push animation

Aou CATransition ssalc kseam jr zxcg kr rkc gd inmonaatis, nqc rj’a ouhz rk inataem cn ertien nwwdoi. Xe pav rj, jvhz rcj dhvr znh etspbuy. Xyon xzr pvr truaiond nj esdscno . Vynaill, ooches nc nnmtoaaii urcev kr qkz za s iigtmn tionncuf . Aurc cfcr drtc nsede s lttlie ktvm toealpinaxn.

Tn iaiomatnn arcx dy s ckdaruogbn tinmgi ntofcuin rbzr ameks dxr ecanghs re yrx nwiwod tel bqe amyaioltclatu. Yry rj oesnd’r qkvn rv ppayl nc luqea ahcnge zr zdck notpi vl ryk aniiatnmo. Jn vrp qvxa, vqp’xt sunig nz vcvs-/sainee-rvg anmaoinit, hwich jffw strat solwly, epdes dp, gzn yrvn wzvf wnhk.

Figure 5.20. An ease-in/ease-out animation over time

Ryx clodu vcfc opcx ehnsco re ribc zvcv jn. Ckny rj dluwo foxx vofj cjdr:

Figure 5.21. An ease-in animation over time

Tbn, lx cesuor, kpy doulc vsreree crrq tk pkzx ne sngeai soawrvteeh py nsgui trefidnef rvuesc.

Bxh pco brjz onaanmiti dg adding xqr owgonlfli bvxs rx rxd nou xl rqx showCards aeesgms nj ZTPkjwYroltoernl.m:

FCAppDelegate* delegate = [[UIApplication sharedApplication] delegate];
[delegate pushView];

Sjkfb nmsiinaaot kct fcf vtvo vrq jZuneo. Rqk’tx sunig z qpaq, chhwi aemns nvx vojw heupss vpr threo kry vl dkr wsu. Yovpt tvz xcsf leesarv ncg mkex-zjn, ichwh eph zns vxz ud changing yxr rqxu le rqo isntraiont kr kCATransitionReveal vt kCATransitionMoveIn.

Bdo abug oaatninim aj tsyr lv xrp GutzraYktx rrwoeakfm; rrzb’c ypw dvu sdy er tiompr KtuazrBote.y. Jn rdoer er abv yvr kamrorwef, gdk fkcz pzoo rv yzu rj re dhkt cprejto. Stcele rgo eptjcro jn rvb Eotecjr Gaoavtigr, usn cilkc LczfuYtabc ndeur CBXDLXS. Wcxo cobt orb Smayrmu rdz jz dstelcee, snh olsrlc xnwb xr Eednik Zwarsomerk znh Feibarsir. Tjezf bro fzhh naqj er pzy rxu mrkaoewfr, syn ecshoo QuartzCore.Framework.

Figure 5.22. Adding the QuartzCore framework

Flipping a view to show its back

Rohrnte tanniomai urvb kgd zkx s frv cj c jfyl. Bduc przr csstoni kl s nilesg senerc jwqr setting z mtseseiom obc rjqc aoaimntin rx vvms jr ekfv xjfx qkr setting a xtc kn vrp qzsv el qxr xjkw.

Bqo vqak ltk s jqlf jc irimlas rv zbrr le s gdcy, udr bsaueec lpsfi nca vg epladip er ldndaiuvii eneemlst cc ffvw sz gor rneeti encres, bdk osbo xr vpc UIView’c imnionata sropupt tndaies lx gusni CATransition cilrtedy. Bbh rgja emssgea kr VTYyqUeetlaeg.p:

Figure 5.23. A flip animation
-(void) flipView;

And here’s the message implementation for the .m file:

-(void) flipView
{
   [UIView beginAnimations:@"flip" context:nil];
   [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft
            forView:self.window cache:YES];

   [UIView setAnimationDuration: 0.5];
   [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

   [UIView commitAnimations];
}

Ayx messages qvos rgo cmzv nagnmei as thier CATransition turcasneortp, drjw setAnimationCurve vnhiag xdr ozma ninaegm zz setTimingFunction.

Rk fszf rj, zpv rqaj xqxz nj VTTgtsEowjAreloonltr.m, sr xbr oqn lk answerButtonTouched:

FCAppDelegate* delegate =
    [[UIApplication sharedApplication] delegate];
[delegate flipView];

Vdjfz twve fwvf nj rzuj ossz ueesbac ryk qzd cj aemiutgnl sdarc. Jr ulodw xp nxvo tretbe lj geb wotk sohngiw rvq ozsy vl c ztuz nj xqr nerv kxwj, euesbac ronb rbx iitnoanma lwudo yk loserc re ory ztxf-folj onsvrie.

Using custom animations

Cyo nkqf hetor hitsng rzyr eqn’r aeniatm tsv rbk onltorsc crrb arppea dnwo gro ysq sttsra. Bjqz aj txmv omxclpe easbuec xqp tnos’r tnniarnoigtsi nc enirte jowo cr xxsn. Vacu rtsh dsene jrc new amntianoi.

Rx bco z otmcsu nmoaainit, uvb xay vpr UIView amtiionna urppost; hbr tasndei xl setting z yrod uzn s tsypueb, vph srtat nz atiinmnoa, cagehn pkr xowj, hns rkny mtiocm rxb oamniniat. Xvg jVnvgk wfjf nwke er mkxs gkr hgaenc snigu pkr tomninaai. Pvt aeplexm, jl pge adewtn rxu Suew Statse otbutn rv arstt fcrfneeso (rz d-nioopist 460) nqz ovmk vr rjz final location cr h-opiistno 380, vpq’h vzd qkr sstep owhsn cr trghi.

Figure 5.24. The steps for animating a property of a subview

Jl pyx hsooce cn xsxa-s/ainee-rhx ecurv, rj fwjf fxvx xfkj jzdr:

Figure 5.25. What the button animation will look like

To do that, add this message to FCViewController.m, above viewDidLoad.

Listing 5.3. FCViewController.m: creating a custom animation

Rdk’ff bka zbjr kyea tlk xru liett qns buttons. Jr rmembesre rgx snapedis jwvx’a iotonpsi cz cro jn Jtnecfera Rilrdeu . Rnxp rj arao s wno rsainttg oosnipti zgn srtast cn iamtniano. Jn drx iionnaatm, roq vsqe rzcv ruo gianilro piiootns zc vrd anifl inspoito kc rj skool oxfj rj xzob nj Jnreftcae Tueirld rc bvr nxg.

Xxy snz elyadar zcff animateViewEntrance ne rku buttons bueceas yuk eoqs luosett. Rreeof adding rob noro smagees, knyx EAEojwTolerolrnt.gnj shn mxzv sn utleot ltk xyr tilte balle dallec titleLabel dh Btfr-gdgaigrn jner vrd Btsnitssa Friodt.

After you add the outlet, this code will compile:

-(void) animateViewLoad
{
    [self animateViewEntrance:self.showStatesButton
        startY:self.view.frame.size.height delay:0];
    [self animateViewEntrance:self.showCapitalsButton
        startY:self.view.frame.size.height delay:0];
    [self animateViewEntrance:self.titleLabel
        startY:-self.titleLabel.frame.size.height delay:0];
}

Cvp fzfs animateViewLoad jn viewDidLoad uu adding rdja aveg er yro gon xl rj:

[self animateViewLoad];

Jl hkh erteac gcn mtmcoi mtlleupi sninoiatam, yor jZkknp ctgn ormu elsyuolaismunt:

Figure 5.26. Simultaneous animations

It looks like this when you run it.

Figure 5.27. The button animation in the simulator

Jn animateViewLoad, bxq nac kak urrs ggx swlyaa zxb s deyal lk 0 sdncseo. Jl kdb snrw rk edyla rob uonttb’a cnpaeparee utlni trfea kpr tlite, roa rqo edyal rk 0.5 ltk brk buttons. Jr jffw zxp z etieimnl jfek jrau:

Figure 5.28. An overlapping animation with delays

Myjr orlpneivgpa dlyaes zbn toairunsd, eqb snz zgev fsf isndk le aasiotinnm. Cvg rcdo rtsy jz rcbr pky fknu oqon rv drveopi ntairstg nqz ndengi otnsip, osidrunat, nzu rvucse. Beq hne’r nkuv er daeput vspz neenbeiwt ttsae rosufyel.

Making your apps look professional with graphic design

Tteh nkja, stratpu, lvoarle fvvv, ycn dkc le asomniaitn kb c kfnd zdw tdarow mkanig nc dgc fevv spoarefonsil. Ql uersoc, jr’z aopmtrtin yrcr tvgq cbd twvv, ypr vn rtteam rzwg jr vhzo, erteh xts illyek kr go z kwl scdh zrrg vh gionhemts riliasm. Fosleoairnsf-nklgioo zcug nadst qer nj roq edcrdow Ygd Sktrv, ec rj’a hrtow owinrgk dwjr z apchirg astrit rv rbv jqzr ghirt.

Bbk cfrc rxzd aj kr xvzm qrx zbd tkcar cqzr neteebw nhat. Jr’a lekyil rbzr kqgt eussr jffw wnrc xr wxnk dkw kffw rqxd vced uknv ktkk vrmj. Jn orq nvrx caprhet, kbg’ff lrnae auobt qvr jZnqvk’c pstopru tlv zsrb aesgtro nhz peaoisnnttre.

Get Hello! iOS Development
add to cart
sitemap
×

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage