[英]UITableViewCell's text label alignment to top in IOS
我正在使用UITableView。
UITableViewCell *tableViewCell = NULL;
tableViewCell = [historyTableView dequeueReusableCellWithIdentifier:@"Table cells"];
現在,如何將opt對齊方式設置為tableViewCell.textlabel?
我也嘗試過setFrame,但是沒有用。
感謝Jithendra
使用此鏈接可獲取UILable的Verticale對齊文本
你的要求,否則替代的解決方案是,你可以使用UITextField
,子類UIControl
,它繼承UIControl年代contentVerticalAlignment
屬性。
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
您可以使用此屬性在頂部對齊文本。 您可以使用屬性userInteractionEnabled
屬性來禁止用戶編輯文本。
也可以在這里看到這個label-aligning-in-uitableviewcell許多代碼
希望對您有幫助...
您可以使用
tableViewCell.textLabel.textAlignment = UITextAlignmentRight; //you can use UITextAlignmentLeft, UITextAlignmentCenter aslo!!
對於垂直對齊,您需要使用sizeToFit:
方法
另請參閱波紋管鏈接
您可以通過這種方式使用默認的tableViewCell.textlabel設置TOP align
[cell.textLabel sizeToFit];
享受編程
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.