Created
December 1, 2017 13:00
-
-
Save ignazioc/9ff18fa1a3663c3108f51c3de1626e08 to your computer and use it in GitHub Desktop.
This file contains 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
import UIKit | |
import PlaygroundSupport | |
class MyViewController : UIViewController { | |
override func loadView() { | |
let view = UIView() | |
view.backgroundColor = .gray | |
let textView = UITextView(frame: CGRect(x: 20.0, y: 30.0, width: 300.0, height: 400.0)) | |
textView.textColor = UIColor.blue | |
textView.backgroundColor = .white | |
view.addSubview(textView) | |
self.view = view | |
let str = NSMutableAttributedString() | |
var attributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 22.0)] | |
do { | |
let primo = try NSMutableAttributedString(string: "<b>Ciao</b>", attributes: attributes) | |
str.append(primo) | |
}catch{ | |
//error | |
} | |
textView.attributedText = str | |
} | |
} | |
// Present the view controller in the Live View window | |
PlaygroundPage.current.liveView = MyViewController() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment