how to text.append() a Hyperlink to TextEditor Swiftui - swiftui

I have a TextEditor that i want to add a clickable Hyperlink using the TextEditor text.append()
TextEditor(text: $textE)
.textFieldStyle(.roundedBorder)
textE.append(contentsOf: "\n" + LINK......)

I believe you have to use markdown to achieve hyperlink in text.
Text("Hello! Example of a markdown with a link [example](https://example.com)")
This question may be useful for you about how to use uitextview

Related

Adding 'Text Shadow' on selected text in Quill Rich Text Editor

Is there a way to add a custom button which adds 'text-shadow' to selected text?
Thanks!

SwiftUI - How to apply markdown to TextEditor?

With iOS 15 and Swift 5, I can add markdown to text, e.g
Text("Regular")
Text("*Italics*")
Text("**Bold**")
Text("~Strikethrough~")
Text("`Code`")
Text("[Link](https://apple.com)")
Text("***[They](https://apple.com) ~are~ `combinable`***")
But is it possible to somehow apply this to TextEditor as well? Can a user highlight some written text and apply specific markdown format to that text?
TextEditor(text: $notes) // how can $notes accept markdown here?
Maybe do this:
Text(content).lineLimit(nil)

SwiftUI - How to make part of a Text Navigation Link in iOS 13?

I have Two Text views containing a bold part and a not bold part added by + operator in SwiftUI. Like Below:
Text(AppStrings.dummyName)
.bold()
+ Text(" \(AppStrings.dummyMemberRequest)")
I want to turn the Bold part into a NavigationLink. But it is not possible as + Operator only works with Text view.
How can I turn a part of the Text view into a NavigationLink in SwiftUI, iOS 13?
You can just use Markdown syntax instead of combining them like that
Text("This is a text with **bold** words")

How to use bold and normal text in same line in SwiftUI

I want to use multiple text formats in one Text view in SwiftUI. this would look like this:
i want to have multiple formats for text in the same text box at the same time even if it is really really really really really long text so it would need to wrap correctly. (and maybe even include links!)
I found this(How to bold text in TextField swiftUI?)  thread after a basic search, but it is not at all what I am looking for.
This would work similar to HTML's span
Here a simple example for you, with my example code you can code for iOS 13 or 14 as well:
struct ContentView: View {
var body: some View {
Text("Hello, World!") + Text(" Hello, World!").bold() + Text(" Hello, World!").italic()
}
}
output:
With iOS 15, you can use markdown for Text:
Text("i want to have multiple **formats** for text in the _same **text box**_ at the same time even if it is really _really_ **really _really_** ~~really~~ long text so it would need to wrap correctly. (and maybe even include [links](https://www.apple.com)!)")
Result:

Newbie question. How to set TextField's horizontal size to N characters

Sorry if the question has been already answered. I'm new to Swift, and I want to create a simple fixed-size TextField for one-time password:
TextField("******", text: self.$otp)
.padding()
.textContentType(.oneTimeCode)
.keyboardType(.numberPad)
I was hoping to find a configuration parameter similar to <input size="6"/> in HTML so that the engine would automatically compute the TextField's size for N characters.
Is there a simple solution to this without jumping through hoops like using ZStacks and spawning N text fields as I saw some enthusiasts were suggesting?
Use a fixed size TextField.
TextField("******", text: $text).fixedSize()
you can use frame for such tasks:
TextField(title, text: binding).frame(height: 40)
or
TextField(title, text: binding).frame(width: 40)