2015-12-14 3 views
1

Может кто-нибудь сказать мне, как изменить размер текста в Tableview так, чтобы текст на скриншоте ниже помещается в ширину экрана:как изменить размер текста в Tableview

enter image description here

Ток tableView код:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) 
    cell.textLabel!.text = self.dataArray[indexPath.row] 
    cell.imageView!.image = UIImage(named: "20x20_empty-round-radiobutton-choice-ui") 
     return cell 
} 

Заранее благодарен!

+0

перейти к свойствам TextLabel в раскадровке и изменить Autoshrink к другому варианту – Tj3n

ответ

2

Попробуйте следующий код:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) 
    cell.textLabel!.text = self.dataArray[indexPath.row] 
    cell.textLabel.font = UIFont(name: cell.textLabel.font.fontName, size:15) // Change the font size as per your requirement 
    cell.imageView!.image = UIImage(named: "20x20_empty-round-radiobutton-choice-ui") 
     return cell 
} 
+0

Спасибо. Задача решена! – mhs5819

1

Установить минимальный шрифт автозапуска. Если ваш текст достаточно длинный, чтобы превысить фактическую рамку метки, тогда ваш шрифт будет уменьшен до минимальной шкалы шрифта, который вы предоставляете в раскадровке или xib.

Auto Shrink minimum font scale 0.5

Смежные вопросы