Измените размер шрифта в раскрывающемся меню боковой панели от программирования в Swift
По поводу следующего изображения:
Как мне увеличить размер шрифта?
Это код BackTableVC.swift
:
import Foundation
class BackTableVC: UITableViewController {
var tableArray = [String]()
override func viewDidLoad() {
tableArray = ["event log", "my details", "research", "share", "checklists", "templates", "helpful links", "feedback"]
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableArray.count;
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: tableArray[indexPath.row], for: indexPath) as UITableViewCell
cell.textLabel?.text = tableArray[indexPath.row]
cell.textLabel?.textColor = UIColor.white
return cell
}
Как мне увеличить размер шрифта? Есть идеи?
2 ответа
import UIKit
class BackTableVC: UITableViewController{
var tableArray = [String]()
override func viewDidLoad() {
tableArray = ["event log","my details","research","share","checklists","templates","helpful links","feedback"]
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableArray.count;
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: tableArray[indexPath.row], for: indexPath) as UITableViewCell
cell.textLabel?.text = tableArray[indexPath.row]
cell.textLabel?.textColor = UIColor.white
cell.textLabel?.font = UIFont.systemFont(ofSize: 25)//set your font size replace the 25 with your font size
return cell
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: tableArray[indexPath.row], for: indexPath) as UITableViewCell
cell.textLabel?.font = UIFont.systemFont(ofSize: 20)
cell.textLabel?.text = tableArray[indexPath.row]
cell.textLabel?.textColor = UIColor.white
return cell
}
В приведенном выше примере вы будете изменять размер шрифта, но не семейство шрифтов, если вы также хотите изменить семейство, вы можете использовать этот код.
UIFont(name: "Avenir-Book", size: 16)