Swift---UIView addSubView(UItextView),无法显示任何内容
没有显示任何内容,有什么问题 在swift 3中,您应该写下:Swift---UIView addSubView(UItextView),无法显示任何内容,uiview,swift3,addsubview,Uiview,Swift3,Addsubview,没有显示任何内容,有什么问题 在swift 3中,您应该写下: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. //let attstring = NSMutableAttributedStri
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//let attstring = NSMutableAttributedString
let testTextView = UITextView.init(frame: CGRect.init(x: 0, y: 0, width: 100, height: 100))
let attstring = NSMutableAttributedString.init(string: "You can check flights from the past 4 days, or plan 3 days ahead.\n\nTo find out when and where we fly for the rest of the year, please view our Timetable.", attributes: [NSFontAttributeName:UIFont.boldSystemFont(ofSize: 12),NSForegroundColorAttributeName:UIColor.red])
attstring.setAttributes([NSForegroundColorAttributeName:UIColor.blue], range: NSRange.init(location: attstring.length-10, length: 9))
print("test test!")
self.view.addSubview(testTextView)
}
let testTextView = UITextView.init(frame: CGRect.init(x: 0, y: 0, width: 100, height: 100))
let attstring = NSMutableAttributedString.init(string: "You can check flights from the past 4 days, or plan 3 days ahead.\n\nTo find out when and where we fly for the rest of the year, please view our Timetable.", attributes: [NSFontAttributeName:UIFont.boldSystemFont(ofSize: 12),NSForegroundColorAttributeName:UIColor.red])
testTextView.attributedText = attstring
attstring.setAttributes([NSForegroundColorAttributeName:UIColor.blue], range: NSRange.init(location: attstring.length-10, length: 9))
self.view.addSubview(testTextView)