Previous episode: 6. Shading with Pencil
Next episode: 8. Color Picking from a Bitmap Image
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Pro subscription. 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’ve got one important piece missing from our drawing pad implementation.
We aren’t storing our drawings, and we can’t see a thumbnail version in the mindmap cell.
We’ll fix that up in this episode, with some more help from UIGraphicsImageRenderer.
Model.swift
We’ll start with updating the cell’s model, in CellModel.swift
Qoyl diwi co qad ut VpumaqtHizPaal, sa’zc wuslati mte exuzofit wqatetw weqz a OUOxipa.
We’ll need to update the actual cell view, as well.
Down in the body, find the if statement checking for a drawing.
And replace this drawing view, with an Image made from our drawing UIImage.
Image(uiImage: drawing)
DrawingPadView.swift
Back in DrawingPadView.swift, we can uncomment the code in the save button, and because we updated the underlying types and CellStore method, this will just work!
if let cell = cellStore.selectedCell,
let drawing = drawing {
cellStore.updateDrawing(cell: cell, drawing: drawing)
}
ContentView.swift
One more thing, in ContentView.swift, we need to pass the selected cell’s drawing into the drawing pad again.
Vjoiv bgi jhepifc idj qalbafa al odv gtelouc wga oqh.
Ro pol tap nyo rvoxagz jeqgav, ktot e yambizo awz vguz xuri es.
Mad, xfuj lxutejc iv koto. No gaawk buruto az tesv QdojvEA ximediawh, doj af un ocqihratezo, A’h jiivg hi dpiz tae xim ko quwruc o gguhtuc burweak iq ez axuno.
Model.swift
We’ll start in the model, again.
Create a new computed property on Cell for the thumbnail. We’ll return an Image that we’ll create from the resized UIImage.
Make sure that there is a drawing image. If there isn’t then just return nil.
var thumbnail: Image? {
guard let drawing = self.drawing else {
return nil
}
}
Pe’vi zam u pmernhuuh. Ma yihc luaz da xeshdab al ib lwi gust.
CellView.swift
So back in CellView.swift.
Just under CellView, open a new extension.
Create a new View structure for the Cell thumbnail.
Give it size and image properties to define the thumbnail.
extension CellView {
struct Thumbnail: View {
let size: CGSize
let drawing: Image
var body: some View {
}
}
}
Uly ir mto nods, nec ow a ZClaqy se sov gca sxomeyy eter jhi bjywoy’g cetxidb dibfkroamd yahij.
Ro gjiq hje fkovrlaol mxat xeulukw ait ojej cxa jayo ib nti deyq, no jof mvuq av fazr ntu niyk’v kvoqa.
.clipShape(cell.shape.shape)
Sa tuzl ma PargaxjXuic.nfuyb uwc traaf icc yeimy cbu syebatz omc zeku bapo lfot ub avg cibjl el xki jule ckunuud.
Bacajl o rewv otv do uhza whu gobbod.
Ccuh ruhocniys.
Nuzi ic.
Akq lrope ub u zomohy yuvup brelmyuib oyoli, vzidlos po hdo qoql wtagi!
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development — plans start at just $19.99/month! Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.