Skip to content
Snippets Groups Projects
Commit d0e6e22f authored by kondeichmann's avatar kondeichmann
Browse files

layout Text

parent bf55485e
Branches
No related tags found
1 merge request!14Feature/invitation
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -22,6 +22,8 @@ extension SendViewController { ...@@ -22,6 +22,8 @@ extension SendViewController {
@IBAction @IBAction
fileprivate func encryptSelectedText() { fileprivate func encryptSelectedText() {
self.invitationSelection.selectedWords.insert(self.textView.selectedRange)
self.layoutText()
} }
@IBAction @IBAction
...@@ -47,6 +49,7 @@ extension SendViewController { ...@@ -47,6 +49,7 @@ extension SendViewController {
fileprivate func removeAllInvitationMarks() { fileprivate func removeAllInvitationMarks() {
self.invitationSelection.selectedWords = Set<NSRange>() self.invitationSelection.selectedWords = Set<NSRange>()
self.layoutText()
} }
fileprivate func menuControllerItems(for textView: UITextView) -> [UIMenuItem]? { fileprivate func menuControllerItems(for textView: UITextView) -> [UIMenuItem]? {
...@@ -55,6 +58,26 @@ extension SendViewController { ...@@ -55,6 +58,26 @@ extension SendViewController {
UIMenuItem(title: "entschlüsseln", action: #selector(self.decryptSelectedText)) UIMenuItem(title: "entschlüsseln", action: #selector(self.decryptSelectedText))
] ]
} }
fileprivate func layoutText() {
guard self.invitationSelection.selectedWords.isEmpty == false else {
self.textView.text = self.textView.attributedText.string
return
}
let selectedRange = self.textView.selectedRange
let text: String = self.textView.text
let orangeColor = #colorLiteral(red: 1, green: 0.570499897, blue: 0, alpha: 1)
let attributedString = NSMutableAttributedString(string: text, attributes: [NSFontAttributeName: self.textView.font!])
for range in self.invitationSelection.selectedWords {
attributedString.addAttributes([NSBackgroundColorAttributeName : orangeColor], range: range)
}
self.textView.attributedText = attributedString
self.textView.selectedRange = NSRange(location: selectedRange.location, length: 0)
}
} }
// MARK: - MarkHandler // MARK: - MarkHandler
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment