Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> iOS

วิธีเปลี่ยน Font และสีข้อความใน UITextView บน iOS

เปลี่ยน Font และสี UITextView ง่ายๆ แค่ตั้งค่า textColor และ font

ขั้นตอน

  1. Main.storyboard: เพิ่ม UITextView
  2. วิธีเปลี่ยน Font และสีข้อความใน UITextView บน iOS
  3. สร้าง @IBOutlet ชื่อ textView
  4. ใน viewDidLoad:
    textView.textColor = UIColor.cyan
    textView.font = UIFont(name: "Callout", size: 20)

โค้ดเต็ม

import UIKit
class ViewController: UIViewController {
@IBOutlet var textView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
textView.textColor = UIColor.cyan
textView.font = UIFont(name: "Callout", size: 20)
}
}

ผลลัพธ์:

วิธีเปลี่ยน Font และสีข้อความใน UITextView บน iOS