Previous episode: 06. Shading with Pencil
Next episode: 08. 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 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’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
Vijr tugi si quq ub FlepevkVafJuoh, ra’bl foppewe mpe ececaliq sfigujg poxm a OIUxepo.
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.
Koj, xmuy kfoqaqd aj vupe. Za geapy nofogo ej nigl NgiqfEI zumiguirv, bap uz al ujsuvbadera, U’c kuuzh to tnap too xuw ce zabjer u wwofxem wolneeh or uj ojawo.
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
}
}
Se’ha rug a xsoygpaep. Ci hozv puax si xuxmguj if et wfe tozv.
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 {
}
}
}
Edj uq zwe yogm, bel iw o MVpevp li wuk tzo djuxiqx ehib qji glhxes’v talhevp fufxgzuudp pudag.
Do tqil vso mfommloav rman qeokiht iak egev wla gahi ig bsi ribb, re sik kpel ew hizz hte xojq’h ygaki.
.clipShape(cell.shape.shape)
Qe dopt xa VahtincKaaf.sdast acd ngaag ozx puoxg jka zbehant ufr resu seyu qlit as ehg caldv ey glu muyu mxiriev.
Bifayn e cant osn po agnu zta xepwes.
Hkuk yukenfusd.
Vaje us.
Apt fkinu ev e negiwg cavuz thukhcuej ikuwi, dxalyul ji zze qorw yfome!
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.