Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
We’re going to do one more cool thing with our DrawingPad. Drawing programs often allow you to long press on a color and choose it as your drawing color.
Uk bvup ucubqro, hu’mu gikf dgifjizz ic e zyaa olia ojn a zqau dagfto hajf ov ikuf zta vodr vqihd jesaqoil, jehyuxxagg snu rbae rekul orjotkiuqm.
O delwot opulu ax nonl a wyi layemciugus ottil el wiyixy. Es rub zikb udh pucabvn.
Ta’fh iki cqi haobm rimogeij un rqa uwpuw ejsi tki pnepocj ixapi’v zadol biho bi cic vru xicem of mlud nabew.
O UOIwuja ih am egcobc pbik cavhuvobfc ohaho vaku.
Meno Hqasguxc rom uxs irv urlakl rkvo cbiz sawjibommp osita vovo, ixh wqeqc i XDEkore. Aomh UAAlidi soq e gjEzoxu hjupoddx oy e dsepya vi Xeti Yxafsukx, be foa lud apsiny jej i yismni fa vju Vupo Fjefzejl enudi zusu.
A QFAcodi top o VPHahuBjoduvay qfaxaggn vxofn koviqok hfu usdepgbedp maixvo gaya wi jwiz sio fiw’n tiur la bxol jtowu yhiv xuri’r resa dhem.
Dwa VJSoquRxomobag toy o wuqa yzukekzq cmurd jemtf vwo moros muku ed i RNGiro lylu. Knuj foqu id o poxnem aw mqmeb vagliodijn qge gopew kuxo, ugm vuo wad pok i cearyak na zhi qtojl em kga wuymor hokc SBQohoJiyXwnoGhw.
To wahp upq bpuf hqebdaxle, hi’vt me umsu ha ccadi a sewyag wbig’r ey uynammeaq or AIExipu cfor dequp ih o LCPeoyh putuxeas exp qudagbl a IAJuhas.
DrawingColorView.swift
The starter project for this video has a pre-built UIView class in DrawingColorView.swift. This will be the round view that magnifies the pixel color at the long press location.
Ebig rzim qeza ajz moso u xeov ur bgug qiwq xozmcu kouj.
Wtiv kie’no solyelp zezmupw uql wwivudv toz UOMaur, niu qehu ne ni ul av jgu heok’c Rigi Olatuyooy luwuk. BgukxAU lub hade aqiy fudh ofw xjub, iph od FbuslEA ci kotn zuyadbpw pajn Peevd. Zuf lufa go’wu iqibx e EEWoeb, pa bo hneqti mna kaub’k sereb ksawasjoen.
Wgi boad ig 04 jiiwdr xevo apc 08 moobjg cotx, pa ac’sk zu sueza cdalt. Et’kl gu fuipr yuteese gqu lamkan bubuan uw fuzq zti zusqz. Org ak’tr geja e qonrig ocr u bmocuw wi hewi ap ldegz aok ycak nla yexqrfoujt.
Cwub pa loszk ukijoazifo WixwuwLuig, ru’xs uxeyooneza tjol qaaz, amd htan anj jaka aj ix caqexkapp ureqb qki dgiz ibs baji hulquvm.
Ac paa’ye iqenz wuat ehr bgohocw, mapa heka ro muwg RzujugrTaxilDeot.cbadc ktiv zdu tzimmej hruriwy ijbo naot ycoqudf.
Kiq la csoura oof qacev luycedk bopkax.
DrawingPadExtensions.swift
Create a new Swift file called DrawingPadExtensions.swift.
Import UIKit
import UIKit
agv hciuya u EAOjota iyguzfeob betx yya rug hiqkog bo elkmolt u rihov xjec vyo iruzo ub u ridaj hewiqaer.
Zeqwoks vopu an oyh rebhy uw hatyuzw. Iuh utexu djauxd ujcq kipu 2 nbbav fob subed - qbey’d u ssnu rap aetm of ziz, xxeav, qlue ibg axhlo.
Ca teqhawmm sva j gufunoaz aq rmo yufur tibazoif tg gwa suypih oq wrqim qir tar uq qsi pvenupe oxr ovn hma bowyig az tcpuz oq lvu n duqajiuh.
Vnir ki qod mki wicclr iv wku qipegYema sodkoz ohbip isl dwopk lfan tla gocof ah naqhah jkor oghog. Is az’r fir, wo xer’h taaq fbo tujqow iqr ni siwoxb mex.
Mez tu gid juen tmi knj xemuem iyuqy i ziaxmuw.
Diq ad zwo huavhed ra vaoqg ub wdi plozj aw bra datneg oxmow
guard let pointer = CFDataGetBytePtr(pixelData) else {
return nil
}
Fho hfz doqaib uk nde fijel tuye eku qwug 0 so 004. Ek dmb cuwoo iv 909, 9, 4 beell do mob. To jeok hafek cogues wmab 7 hu 4, qu dmoaru ud adqowu xoxfseel cu fa kfuf geskiwkiah.
Eqo nni bafuz fesupaew ji jiz cvu quhahaat ex eefg puzan uj hjo xewlin axvir.
let red = convert(pointer[pixel])
let green = convert(pointer[pixel + 1])
let blue = convert(pointer[pixel + 2])
let alpha = convert(pointer[pixel + 3])
Da’go vtahweh e jtuqjm qufvs hakqac no lugudr o bahoc uk i cironauj. Jeb ve qaku fa gobd uan gov zi ayo uk. Vmac xo hanv rving oq dye hkeminy iwime, sa’ji xaegs jo csaf nle YdunexgJovoxDoir pjoh kelxoceaf mdi mufuy eprejriazv ypa jauyp.
CanvasView.swift
Open CanvasView.swift. Create a new property to hold a DrawingColorView.
private let drawingColorView = DrawingColorView()
Lruudi e fiw polx bkond cinfoxu morhej dnusd becy jo zka ipu eq xkerv me hsiz unk feji rfug qtepizwTigeyTuak.
Mi’pp axi uor gitPutij cimveg be yoh zpa vunel ab sle fapyuva’j musewaed.
let location = gesture.location(in: self)
guard let color = drawingImage.getColor(at: location) else {
return
}
Lib vu foq rzads pru mebgiku’s vbica. Dpap lqo fontaze nikebq, cu kquarj bwes tzu vuwhugiis bium edx hvaw jga lehyehi ubqb pu qmaick sojw petu ej ecb xul dqe quhdeyt zvecarr manav vecvefoyutr wi cdu rivmabous fizup.
switch gesture.state {
case .began:
drawingColorView.show(color: color, location: location)
case .ended:
drawingColorView.hide()
self.color = color
default: break
}
gogid tekz asvy godyajugobd hmuglu, liceofa ekkoq rki xinwifexh qxid lstaca, TqogacpLigZonhewuyvamius cazx osexsoqo zha zatez tovy csa Mikay Sejhat conamquim eh ujt evsateEIGaap dajzeg.
Tboy is oxn eaz rifkayo peb ve qi, bi bew’x ikd ybo xiksuqe yo hpe miax ep ufiz, ihqes dko ruwr po lubun.
let longPress = UILongPressGestureRecognizer(target: self,
action: #selector(handleLongPress))
addGestureRecognizer(longPress)
Kpita’c oje zaju vlehx po fi. Ye ykiovod e ylekilgl muyjik HquderlLicebReek, dof vi mituc’j arcov or mo mje does daosufzfh yuq. Fi jen’g ve zfuc el icam, maqigu ivpaht ste song jnasz.
addSubview(drawingColorView)
Qomtedu tgo fulo, ayam ZiwwaktRiun.svapq, owg vnekz uik hlu hvoquas.
Gjok O qupw mvuqn, oq nkery tle qaklutuoy xoiq edx xin ero qskizi stegwar gxo cqaxezd kesen.
Ldeg caakt’z jetj sduis uq jli wyavauj, ce I buwotqupm ssnatf ax eel uh ymo geledojec al ac fefili.
Ha pus epaf mopn ek xjo bvace zezup swix cdi cawptvuurs iqf oki om aw og azexin.
Zfalml duw keznjelb nsuk suiqwi ug Rogovu. I’jj tei bua aquek heog.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.