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
Post
Replies
Boosts
Views
Activity
Your fontName is incorrect, it's missing an r at the end, it should be @"HoeflerText-Regular".
Adding an r resulted in this image:
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.
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()
}
}