斯威夫特的UITableViewCell对齐 [英] Swift UITableViewCell Alignment
本文介绍了斯威夫特的UITableViewCell对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示一个页面,像下面的
I am trying to display a page like the following
页面标题(左对齐)
域名(居中对齐)
人在该地区(字幕,在细节标签电子邮件)
people in the region(subtitle with email in the detail label)
但是,如果我选择字幕的单元格样式,一切都将左对齐,我不能在code更改。然后,如果我选择定制的风格detailtextlabel不会显示。
But if I choose subtitle as cell style, everything will be left aligned and I cannot change them in the code. Then If I choose custom as style the detailtextlabel will not show.
if(poDetailList.LastName == "POName"){
cell.backgroundColor = SharedClass().coopGroupHeaderColor
let selectedColor = UIView()
selectedColor.backgroundColor = SharedClass().coopGroupHeaderColor
cell.selectedBackgroundView = selectedColor
cell.textLabel?.textColor = UIColor.blackColor()
cell.textLabel?.font = UIFont.boldSystemFontOfSize(15.0)
cell.textLabel?.textAlignment = .Center
cell.accessoryType = .None
var t_header = ""
if(POShort != "OTHER" && POShort != "all" && POShort != "invalid"){
t_header = POName
}
else{
t_header = POName
}
cell.textLabel?.text = t_header
cell.detailTextLabel?.text = ""
cell.userInteractionEnabled = false;
} else{
cell.backgroundColor = indexPath.row % 2 == 0 ? UIColor.clearColor() : SharedClass().cellBackGroundColor
let selectedColor = UIView()
selectedColor.backgroundColor = SharedClass().selectedCellColor
cell.selectedBackgroundView = selectedColor
cell.textLabel?.font = UIFont.boldSystemFontOfSize(15.0)
cell.textLabel?.textAlignment = .Left
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
var t_header = poDetailList.FirstName
cell.textLabel?.text = "Name:" + poDetailList.FirstName + " " + poDetailList.LastName
cell.detailTextLabel?.text = "Not Responded In Days:" + poDetailList.DaysNotResponded
cell.userInteractionEnabled = true;
}
谁能帮助我?
Can anyone help me with this?
非常感谢你。
推荐答案
设置对齐方式为标签
cell.textLabel?.textAlignment = .Left
cell.detailTextLabel?.textAlignment = .Right
我希望它的工作!
i hope it work!!!
这篇关于斯威夫特的UITableViewCell对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文