2017-04-17 59 views
-2

改变显示工具栏菜单的字体大小对于下面的图片:从编程迅速

enter image description here

如何增加字体大小?

这是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

http://stackoverflow.com/questions/7957215/how-can-i-change-the-font-size-of-my-uitableview-cell-title –

+0

您可以直接使用此cell.textLabel.font = UIFont(name:“Avenir-Book”,size:15.0) – Aditya

+0

将'cell.textLabel?.font = [UIFont systemFontOfSize:16.0];'添加到'tableView'函数中。您可以将16.0更改为任何其他您喜欢的字体大小。 – SimpleBeat

回答

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) 
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 
    } 
+0

谢谢!此代码适用于我。 –

+0

@PremPrakashBashyal请使用绿色正确的勾号来表示可信的答案,这有助于其他....并且请回答答案 –