Created
November 2, 2019 05:26
-
-
Save laevandus/fe382c146fab5f7e66aa1cba028cc51e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let textView = TokenTextView(frame: .zero) | |
textView.translatesAutoresizingMaskIntoConstraints = false | |
view.addSubview(textView) | |
NSLayoutConstraint.activate([ | |
textView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 16), | |
textView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16), | |
textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 16), | |
textView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16) | |
]) | |
let string = "The quick brown fox jumps over the lazy dog" | |
let attributedString = NSMutableAttributedString(string: string) | |
let value = "value" | |
attributedString.addAttribute(.token, value: value, range: NSRange(location: 4, length: 5)) | |
textView.attributedText = attributedString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment