When I use png, iOS system will automatically cache it in memory after decoded. So if I use the image in two UIImageView of different frame sizes, iOS system only need to decode it once.
But if I use svg icon in different sizes of UIImageView, whether each time is to re-parse the svg data to draw and render. So it is not recommended to use svg, especially for more complex graphics picture, right?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I want push and post a text to next screen when tapping on Button. But NavigationLink need @state property to catch data. How to avoid this? I hope there is a way I only handle data in button action.
Swift
@State var selection: Int? = nil
@State var text: String? = nil
var body: some View {
VStack(content: {
HStack(alignment: .center, spacing: nil, content: {
NavigationLink(destination: Drawing(text: text), tag: 1, selection: $selection) {
Button("complete", action: {
print(self.selection)
print(self.text)
self.text = "hello"
self.selection = 1
})
}
}).padding()
Sometimes I need restrict the painting area in a PKCanvasView. I have tried mask the layer of PKCanvasView and it work fine.
Swift
let mask = CAShapeLayer()
mask.path = cgPath
canvasView.layer.mask = mask
But sometimes it is difficult to get the cgPath. I get the rect and maskImage by use floodfill, how to clip canvas context in PKCanvasView?
Swift
context.clip(to: rect, mask: maskImage)