【Swift】TextViewに枠線をつける
どうも、猫吉(@nekokichi1_yos2)です。
TextViewに枠線を付ける方法を伝授します。
完成形
ストーリーボード
ソースコード
import UIKit class ViewController: UIViewController { @IBOutlet weak var textView: UITextView! @IBOutlet weak var textView2: UITextView! override func viewDidLoad() { super.viewDidLoad() // 枠のカラー textView2.layer.borderColor = UIColor.blue.cgColor // 枠の幅 textView2.layer.borderWidth = 5.0 // 枠を角丸にする textView2.layer.cornerRadius = 20.0 textView2.layer.masksToBounds = true } }