Hi @girishw, have you found a solution to this?
Requesting notification authorisation is not working for me (on Xcode 14.1 beta and macOS 13 beta)
Post
Replies
Boosts
Views
Activity
Use .task to assign the initial focused field instead of using .onAppear
TextField("Placeholder", text: $text)
.focused($focusedField, equals: .field)
.task {
self.focusedField = .field
}
Follow this solution on StackOverflow to fetch data from CoreData for iOS 14 widgets - https://stackoverflow.com/a/63945538/10887876
As I know, this is the best way to add a placeholder text to TextEditor in SwiftUI
struct ContentView: View {
		@State var text = "Type here"
		
		var body: some View {
				TextEditor(text: self.$text)
						// make the color of the placeholder gray
						.foregroundColor(self.text == "Type here" ? .gray : .primary)
						
						.onAppear {
								// remove the placeholder text when keyboard appears
								NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillShowNotification, object: nil, queue: .main) { (noti) in
										withAnimation {
												if self.text == "Type here" {
														self.text = ""
												}
										}
								}
								
								// put back the placeholder text if the user dismisses the keyboard without adding any text
								NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillHideNotification, object: nil, queue: .main) { (noti) in
										withAnimation {
												if self.text == "" {
														self.text = "Type here"
												}
										}
								}
						}
		}
}
Did you guys find any solution for this?