Okay, so it looks like Swift Playgrounds apparently compiles differently from Xcode so it wouldn't compile because of a style "error" (left a bracket on the same line as some other code) despite still compiling on Xcode. Moving it to a new line seems to have fixed my issue.
Post
Replies
Boosts
Views
Activity
Hi! I was stuck on this too, but when I saw your comment, I had an idea. This is kind of a hacky solution, but basically I moved do { try viewContext.save() } catch { print("Failure to save context: \(error)") } to an .onDisappear function. That way the app would save the deletion only after the view is out of sight (because I'm assuming the problem lies in the ForEach statement not knowing how to update the view when its data suddenly becomes empty). I also added a condition so that it only tries to save the view context if something has been deleted. I'm a little late to the party, but I hope this helps you and/or anyone else who comes across this issue!
Edit:
I forgot to mention that I made an extension for UIColor:
extension UIColor {
func circle(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage {
return UIGraphicsImageRenderer(size: size).image { rendererContext in
self.setFill()
UIBezierPath(ovalIn: CGRect(origin: .zero, size: size)).fill()
// rendererContext.fill(CGRect(origin: .zero, size: size))
}
}
}
And the thumb is supposed to follow your touch location and grow and shrink depending on the value. Additionally, if the thumb goes past the end of the slider, translation is supposed to essentially "move" the slider so it's as if the entire slider was dragged to where you moved the thumb.
@Claude31 I'm trying to go for something like this, where if your finger is above the slider, the values change slower. The thumb thing probably made it more confusing, so you can ignore that.
Here's a video of kind of what I'm going for: https://www.dropbox.com/scl/fi/vy2deau3tdgx0nd4yogzo/ScreenRecording_08-15-2024-09-52-44_1.MP4?rlkey=xo3jlc7g6n5ervhw0ft7p01x2&st=v35wnpsk&dl=0
In the video, when I drag the thumb above the slider and move it, the values change more slowly so the thumb size also changes slowly.
Ohhh, I see what you mean! Do you know how I might go about adjusting the position with the scrub speed? I'm not really sure how to make it move slowly "around" a specific value. Maybe I could store the previous value and use that??
@DTS Engineer Ohhh I see, that would explain the antialiasing effect. I would like to know if there is a way to make the stroke pixellated at every point along the line though, so that every pixel is either fully colored or not colored?
@DTS Engineer Ah okay, rounding did improve it, but didn't get rid of it completely. I'll definitely look into aligning the pixel values though, ty!