UITextViewDelegateを継承したらうまく動きましたすみません(´・ω・`)
swift
1class HogeViewController: UIViewController ,UITextViewDelegate{
2
3@IBOutlet weak var textView: UITextView!
4 @IBOutlet weak var titleField: UITextField!
5
6 @IBOutlet weak var placeholder: UILabel!
7 var barColor = UIColor(red: 32/255, green: 143/255, blue: 200/255, alpha: 1.0)
8 var barFontColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1.0)
9
10 override func viewDidLoad() {
11 super.viewDidLoad()
12 titleField.placeholder = "タイトル"
13 textView.text = "Placeholder"
14 textView.delegate = self
15 textView.textColor = UIColor.lightGrayColor()
16
17
18 self.navigationController?.navigationBar.barTintColor = barColor
19 self.navigationController?.navigationBar.tintColor = barFontColor
20
21 }
22
23 //textviewがフォーカスされたら、Labelを非表示
24 func textViewDidBeginEditing(textView: UITextView) {
25 if textView.textColor == UIColor.lightGrayColor() {
26 textView.text = nil
27 textView.textColor = UIColor.blackColor()
28 }
29 }
30 func textViewDidEndEditing(textView: UITextView) {
31 if textView.text.isEmpty {
32 textView.text = "Placeholder"
33 textView.textColor = UIColor.lightGrayColor()
34 }
35 }
36}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。