Skip to content

Instantly share code, notes, and snippets.

@ignazioc
Created December 1, 2017 13:00
Show Gist options
  • Save ignazioc/9ff18fa1a3663c3108f51c3de1626e08 to your computer and use it in GitHub Desktop.
Save ignazioc/9ff18fa1a3663c3108f51c3de1626e08 to your computer and use it in GitHub Desktop.
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