I have done the same thing in SwiftUI using UIViewRepresentable, but toolPicker doesn't show so I checked isFirstResponder property and I found that it was still false after I called canvas.becomeFirstResponder().
Check this out:
struct NoteCanvasView: UIViewRepresentable {
func makeUIView(context: Context) -> PKCanvasView {
let canvas = PKCanvasView()
canvas.drawingPolicy = .anyInput
canvas.delegate = context.coordinator.self
let toolPicker = PKToolPicker()
toolPicker.setVisible(true, forFirstResponder: canvas)
toolPicker.addObserver(canvas)
print(canvas.canBecomeFirstResponder)
canvas.becomeFirstResponder()
print(canvas.isFirstResponder)
return canvas
}
func updateUIView(_ canvas: PKCanvasView, context: Context) {
canvas.becomeFirstResponder()
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
class Coordinator: NSObject {
var parent: NoteCanvasView
init(_ parent: NoteCanvasView) {
self.parent = parent
}
}
}
I found canvas.canBecomeFirstResponder returns true and canvas.isFirstResponder always returns false.
Is this a bug in current version of SwiftUI??
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am working on an app that allow user to taking notes, and I want to support inline editing that means users can use PencilKit feature and edit text in a single note just like the Notes app.
Is there any good idea to achieve this using SwiftUI?
How to add hosting base URL to a package(not a project)?
is it possible to add an existing Swift package to my project as a target?
If I set queueDepth to a value that smaller than 6 ( 5 for example ), the stream will be paused when I start capturing and make it minimized or hidden.
Is that a correct behavior or a bug??
Filed a report: FB11441320
If you configure a Window and a MenuBarExtra in your app, try this:
Open your app and press Command+H to hide it.
Place an iPad or another Mac and connect two devices via Universal Control, and click on the other device to make your mac's menu bar inactive.
Move your cursor back to your Mac(first device), and click on the whitespace of the Menu Bar.
Your App is terminated unexpectedly.
This behavior will only appear on those apps using Window, so to solve this issue, we may need to switch Window to WindowGroup which is not what we want.
I reappear this issue on Apple's ScreenCaptureKit Sample Code. This is a SwiftUI Scene BUG, please fix this.
@main
struct CaptureSampleApp: App {
var body: some Scene {
Window("ID", id: "ID") {
ContentView()
.frame(minWidth: 960, minHeight: 724)
.background(.black)
}
MenuBarExtra(
"App Menu Bar Extra", systemImage: "star"
) {
Text("Hello")
}
}
}
Filed a feedback: FB11447959.
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) }
}
I used a package which contains a XCFramework inside it in my widget target. It’s working fine on iOS, and macOS Widget Simulator.
But when I open widget gallery on macOS, I can’t find my widget.
I tried to run my widget directly inside /Contents/PlugIns/WidgetTestExtension.appex/Contents/MacOS/WidgetTestExtension, it prints out the error: dyld[4767]: Library not loaded: @rpath/myframework.framework/Versions/A/myframework