关于以下图片:
如何增加字体大小?
这是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
}
如何增加字体大小?有什么想法吗?
答案 0 :(得分:0)
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)
答案 1 :(得分:0)
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
}