从swift中编程更改“显示侧边栏”菜单的字体大小
关于下图: 如何增加字体大小 这是BackTableVC.swift的代码:从swift中编程更改“显示侧边栏”菜单的字体大小,swift,menu,side-menu,Swift,Menu,Side Menu,关于下图: 如何增加字体大小 这是BackTableVC.swift的代码: import Foundation class BackTableVC: UITableViewController { var tableArray = [String]() override func viewDidLoad() { tableArray = ["event log", "my details", "research", "share", "checklist
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
}
如何增加字体大小?有什么想法吗
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)
您可以直接使用此cell.textLabel.font=UIFont(名称:“Avenir Book”,大小:15.0)添加
cell.textLabel?.font=[UIFont systemFontOfSize:16.0]代码>到您的表视图
函数。您可以将16.0更改为您喜欢的任何其他字体大小。@PremPrakashBashyal请用绿色右勾选择值得信任的答案,以帮助其他人…并请对答案投赞成票
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
}