Hello. I'm implementing a webview in my app. Recently I'm using presentationDetents(_:) which is supported in iOS 16. And I found a problem in this Instance Method.
PresentationDrag Indicator disappears in dark mode. It does not disappear when used in a common View. However, when I use it in htmlView(), this phenomenon appears. [Even if I set Css for dark mode in htmlView(), the result is the same.]
I would be grateful if you could tell me how to solve this. Is there any way to control the style of presentationDetents (frame) or PresentationDragIndicator? (I'm aware of the parameters that hide or show the Indicator, but I'm asking if I can have more control over it.)
in MainView:
...
...
.sheet(isPresented: $activeSheet) {
VStack(){
HTMLView(html: urlToOpenInSheet)
.presentationDetents([.medium, .large])
.padding(5)
}
}
...
...
in htmlView:
struct HTMLView: UIViewRepresentable {
let html: String
class CoordinatorHTML : NSObject, UITextViewDelegate {
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
print(URL)
return false
}
}
func updateUIView(_ uiView: UITextView, context: UIViewRepresentableContext<Self>) {
DispatchQueue.main.async {
let addCss = "<head><style type=\"text/css\">" +
"""
@font-face {
font-family: "Avenir";
}
body {font-family: "Avenir"; font-size: 14px; line-height: 1.0; margin: 30px;}
"""
+ " </style></head>" + "<body>" + html + "</body>"
let data = Data(addCss.utf8)
if let attributedString = try? NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil) {
uiView.isEditable = false
uiView.isSelectable = true
uiView.attributedText = attributedString
}
}
}
func makeUIView(context: UIViewRepresentableContext<Self>) -> UITextView {
let uiTextView = UITextView()
uiTextView.delegate = context.coordinator
uiTextView.isScrollEnabled = true
uiTextView.backgroundColor = UIColor.white
return uiTextView
}
func makeCoordinator() -> CoordinatorHTML {
return CoordinatorHTML()
}
}
And attached image:
- Light Mode
- Dark Mode