最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】swift中如何设置text的textAlignment

Swift crifan 6315浏览 0评论

【背景】

之前折腾Swift的UITableViewCell期间:

【已解决】swift中在UITableViewCell的一行右边添加内容

已经实现了cell的显示内容了:

UITableViewCell single line already show ok

但是想要去设置红色新加的字符的右对齐。

已经去试了试代码:

cell.detailTextLabel?.textAlignment

但是却不知道如何设置值。

即,想要去设置一个text的textAlignment

【解决过程】

1.去搜:

swift how set textAlignment 

参考:

enums – Swift. UILabel text alignment – Stack Overflow

去试试:

NSTextAlignment.Center

或:

.Center

try NSTextAlignment right to see effect

 

【总结】

设置text的textAlignment,swift是用:NSTextAlignment.Center,NSTextAlignment.Right子类的。

转载请注明:在路上 » 【已解决】swift中如何设置text的textAlignment

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.174 seconds, using 22.04MB memory