Post

Replies

Boosts

Views

Activity

Reply to CIImage generate CGImage is unavailable
It renders as expected. However your texture background's is black just like your text colour. Because CGContext is premultiplying alpha. If you change the context's background to red for example, you will see it. CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast|kCGImageByteOrder32Big); CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]); CGContextFillRect(context,  CGRectMake(0, 0, width, height)); To bypass CGContext all together, try rendering directly to an MTLTexture using CIContext's render(_: to: commandBuffer: bounds: colorSpace:), you can find more info here: Apple Developer Doc
Topic: Graphics & Games SubTopic: General Tags:
Nov ’22
Reply to SWIFTUI DatePicker with Calendar identifier
To make SwiftUI's DatePicker display different calendars, you need to set the calendar environment value. .environment(\.calendar, Calendar(identifier: .hebrew) Using your example, to display a Hebrew calendar add the modifier above Struct DateView: View { @State var selectedDate = Date() let dateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateStyle = .medium return formatter }() var body: some View { DatePicker("Please enter a date", selection: $selectedDate, displayedComponents: .date) .datePickerStyle(WheelDatePickerStyle()) .environment(\.calendar, Calendar(identifier: .hebrew)) Divider() Text ("You selected \(selectedDate,formatter: dateFormatter)") Spacer() } }
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22
Reply to CIImage generate CGImage is unavailable
It renders as expected. However your texture background's is black just like your text colour. Because CGContext is premultiplying alpha. If you change the context's background to red for example, you will see it. CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast|kCGImageByteOrder32Big); CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]); CGContextFillRect(context,  CGRectMake(0, 0, width, height)); To bypass CGContext all together, try rendering directly to an MTLTexture using CIContext's render(_: to: commandBuffer: bounds: colorSpace:), you can find more info here: Apple Developer Doc
Topic: Graphics & Games SubTopic: General Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to CIImage generate CGImage is unavailable
Your fontName is incorrect, it's missing an r at the end, it should be @"HoeflerText-Regular". Adding an r resulted in this image:
Topic: Graphics & Games SubTopic: General Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to SwiftUI preview layout: size that fits does not work
Preview layouts in Xcode 14 render the layout in live mode by default. To see the layout with .sizeThatFits select the Selectable option in the bottom left. I've highlighted it in the image.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to SWIFTUI DatePicker with Calendar identifier
To make SwiftUI's DatePicker display different calendars, you need to set the calendar environment value. .environment(\.calendar, Calendar(identifier: .hebrew) Using your example, to display a Hebrew calendar add the modifier above Struct DateView: View { @State var selectedDate = Date() let dateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateStyle = .medium return formatter }() var body: some View { DatePicker("Please enter a date", selection: $selectedDate, displayedComponents: .date) .datePickerStyle(WheelDatePickerStyle()) .environment(\.calendar, Calendar(identifier: .hebrew)) Divider() Text ("You selected \(selectedDate,formatter: dateFormatter)") Spacer() } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’22