Use SwiftUI with AppKit

RSS for tag

Discuss the WWDC22 Session Use SwiftUI with AppKit

Posts under wwdc2022-10075 tag

4 Posts

Post

Replies

Boosts

Views

Activity

SwiftUI Form under macOS looks like iOS
I have been migrating from old UiKit to use SwiftUI form, I use of course .formStyle(.grouped). Only issue that I'm having is that under macOS the forms looks a bit like iOS and I didn't find any way to make it look like it was shown on the WWDC with a gray transparent background. Is this not supported out of the box and I need to write a custom code to achieve that look ? or am I missing a configuration ? This is how my current form looks like on macOS : I Would wish if I could make it look like: I do use the same formStyle and Form element but the look is different the background is while and not gray transparent.
1
0
2.3k
Mar ’23
App Terminates when using Window and MenuBarExtra in SwiftUI
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.
0
0
1.4k
Sep ’22
How does CoreText's CTFontManager deal with variable UIFont?
Suppose I make a UIFont like this: let variations = myCustomVariationsDictionary     let key = kCTFontVariationAttribute as UIFontDescriptor.AttributeName     let uiFontDescriptor = UIFontDescriptor(fontAttributes: [.name: Self.name, key: variations])     let updatedUIFont = UIFont(descriptor: uiFontDescriptor, size: uiFont.pointSize) self.uiFont = updatedUIFont —thereby creating a variable font in RAM and saving it to some object. How do I then register that created font in the CTFontManager such that we can access it by name from SwiftUI? The variation name doesn't correspond with any font file on disk; it will be something crazy like "RobotoFlex_wght0BADF00D_YXCD8282384729" (or whatever) and will be different based the values used for each of the variation axes. The problem I'm facing is that you have to specify the font size when you create a given variable font, or UIFont instance. Now, that font is baked in at that particular size, which might not be the appropriate optical size for the final size it might scale to as a result of DynamicType (e.g. as with an @ScaledMetric for the size). But we can't have the wrapper around the CTFont methods use @ScaledFont property wrapper, since this wrapper does nothing unless used on a conformance to View that's actively being used in an actual SwiftUI graph. In other words, it seems like we have to dynamically recreate the font every single time we want to use it in a Text view, which causes all kinds of nasty memory leaks and unbounded growth of RAM not to mention horrible performance. I've looked at various options available in github—there's exactly one SwiftUI wrapper around dynamic fonts, and it's very uninspiring. So here I am, asking you lot for any advice. Really, I prolly need to file a DTS ticket, but figured I'd try here first. Thanks!
0
0
1.1k
Aug ’22
SwiftUI Form under macOS looks like iOS
I have been migrating from old UiKit to use SwiftUI form, I use of course .formStyle(.grouped). Only issue that I'm having is that under macOS the forms looks a bit like iOS and I didn't find any way to make it look like it was shown on the WWDC with a gray transparent background. Is this not supported out of the box and I need to write a custom code to achieve that look ? or am I missing a configuration ? This is how my current form looks like on macOS : I Would wish if I could make it look like: I do use the same formStyle and Form element but the look is different the background is while and not gray transparent.
Replies
1
Boosts
0
Views
2.3k
Activity
Mar ’23
App Terminates when using Window and MenuBarExtra in SwiftUI
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.
Replies
0
Boosts
0
Views
1.4k
Activity
Sep ’22
How does CoreText's CTFontManager deal with variable UIFont?
Suppose I make a UIFont like this: let variations = myCustomVariationsDictionary     let key = kCTFontVariationAttribute as UIFontDescriptor.AttributeName     let uiFontDescriptor = UIFontDescriptor(fontAttributes: [.name: Self.name, key: variations])     let updatedUIFont = UIFont(descriptor: uiFontDescriptor, size: uiFont.pointSize) self.uiFont = updatedUIFont —thereby creating a variable font in RAM and saving it to some object. How do I then register that created font in the CTFontManager such that we can access it by name from SwiftUI? The variation name doesn't correspond with any font file on disk; it will be something crazy like "RobotoFlex_wght0BADF00D_YXCD8282384729" (or whatever) and will be different based the values used for each of the variation axes. The problem I'm facing is that you have to specify the font size when you create a given variable font, or UIFont instance. Now, that font is baked in at that particular size, which might not be the appropriate optical size for the final size it might scale to as a result of DynamicType (e.g. as with an @ScaledMetric for the size). But we can't have the wrapper around the CTFont methods use @ScaledFont property wrapper, since this wrapper does nothing unless used on a conformance to View that's actively being used in an actual SwiftUI graph. In other words, it seems like we have to dynamically recreate the font every single time we want to use it in a Text view, which causes all kinds of nasty memory leaks and unbounded growth of RAM not to mention horrible performance. I've looked at various options available in github—there's exactly one SwiftUI wrapper around dynamic fonts, and it's very uninspiring. So here I am, asking you lot for any advice. Really, I prolly need to file a DTS ticket, but figured I'd try here first. Thanks!
Replies
0
Boosts
0
Views
1.1k
Activity
Aug ’22
Xcode 14 Donut App Sample Code
Does anyone know where to find the sample project?
Replies
2
Boosts
1
Views
2.4k
Activity
Jun ’22