【发布时间】:2020-04-19 03:52:38
【问题描述】:
在表格视图单元格中显示时,是否可以仅将字符串的一部分右对齐?
这是我的示例代码:
var arrayAnimals:Array<String> = ["Dogs \(self.arrayData[1])g","Cats \(self.arrayData[2])g","Rabbits \(self.arrayData[3])g","Crocodiles \(self.arrayData[4])g"]
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath)
cell.textLabel!.text = arrayAnimals[indexPath.row]
return cell
}
在这种情况下,是否可以在每个单元格中将动物的名称左对齐并右对齐其匹配数据?
提前谢谢你!
【问题讨论】:
-
使用detailLabel比较简单,看看这个:developer.apple.com/documentation/uikit/views_and_controls/…
标签: arrays swift uitableview