I'm trying to copying the Colorful Confetti effect in iMessage using SwiftUI Canvas and I am wondering how to apply 3D transformation on each particle.
I have tried to add a projectionTransform in order to apply a CATransform3D, but it rotates all the canvas, not a particular particle, which is not the effect I want.
Currently, I use the very basic ForEach(particles.indices, id: \.self) loop to create each particle and use .rotation3DEffect to apply that transformation, but it may result in a performance issue (so, I tried to use .drawingGroup()).
Is there any solutions to apply 3D transformation to a particular particle in a Canvas??
My code (using ForEach loop):
GeometryReader { proxy in
let size = proxy.size
TimelineView(.animation) { timeline in
let _: () = {
let now = timeline.date.timeIntervalSinceReferenceDate
model.update(at: now)
}()
ZStack {
ForEach(model.particles.indices, id: \.self) { index in
let particle = model.particles[index]
particle.shape
.fill(particle.color)
.rotation3DEffect(.degrees(particle.degrees), axis: (x: particle.x, y: particle.y, z: particle.z))
.frame(width: particle.frame.width, height: particle.frame.height)
.position(particle.frame.origin)
.tag(index)
}
}
.frame(width: size.width, height: size.height)
.drawingGroup()
}
.contentShape(Rectangle())
.gesture(
DragGesture(minimumDistance: 0)
.onEnded { _ in model.loadEffect(in: size) }
)
.task { model.loadEffect(in: size) }
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Error Code: error build: Command CompileSwift failed with a nonzero exit code
My Code:
.backgroundTask(.appRefresh("checkValidity")) {
// scheduleAppRefresh()
// checkRecords()
}
In iOS 16, the primary action of the Menu cannot be triggered. The Menu itself will always pops up instead of performing the primary action.
I have tried to use iOS 15 simulator to preview the same code. It works well.
Description
In Live Activities, we saw many beautiful animations that powered by .numericText() like Text(time, style: .timer), or even Text with .contentTransition(.numericText()) applied.
But it seems like in normal SwiftUI View, these beautiful animations are gone. Instead, we saw a blinking result or fade-in-out result.
Is that exactly right?
ScreenShots
In Live Activity:
In normal SwiftUI View:
App shortcuts can only be added to Shortcut Action List, but not a separate App Shortcuts appears at the bottom of the Shortcuts app.
Now it only has the default Voice Memo App.
It successfully appeared in beta 2/3, but I'm not sure if it appeared in (beta 3 update).
But in beta 4, it disappeared. I have no idea how to make it visible again!!!
Menu {
ShareLink(...)
ShareLink(...)
ShareLink(...)
} label: {
Label("Share", systemImage: "square.and.arrow.up")
}
Here, I have different share options to choose from, and if I tap one of these share link to share sheet doesn't pop up.
Is there any workaround to this issue?
In the past, I use UIApplication.shared.windows.first?.safeAreaInsets.bottom to get the bottom safe area, but in iOS 15, there is an warning shows that windows has been deprecated.
My project is written in SwiftUI, so is there a way to get the global safeAreaInsets again and fits iOS 15?