`
ynial
  • 浏览: 225628 次
  • 来自: ...
社区版块
存档分类
最新评论

ios UITableViewCell 文字缩进

阅读更多
【前提】
 
  UITableViewCell 原本就有他自己的imageView ,希望在这个imageView上再添加一个icon,
 
  textLabel要缩进 icon 寛的大小。


【解决方案】

 
        UIImage *icon  = [UIImage imageNamed:item.icon];
        UIImageView *imgview = [[UIImageView alloc]initWithImage:icon];
        imgview.frame = CGRectMake(5, 10, 15, 21);
        [cell.contentView addSubview:imgview];
        cell.indentationLevel = 2; //缩进层级
        cell.indentationWidth = 10.0f; //每次缩进寛
  


   这种办法即能显示出原本的背景图片 也能显示出icon 同时也解决了 icon和textLabel重叠显示的问题。使用文本缩进动态调整他x轴的位置。
0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics