开发需要用到TableViewCell 文字居中, 搜索了一些资料整理如下
1、创建UITableViewCell时,的模式用UITableViewCellStyleDefault时,文字居中直接用
cell.textAlignment = UITextAlignmentCenter;
就搞定,但是只设置UITableView的透明度,背景透明难以实现
透明度具体实现代码:
cell.opaque = NO;
cell.textLabel.backgroundColor = [UIColor clearColor];
[cell setBackgroundColor:[UIColor colorWithRed:1 green:1 blue:1 alpha:0.2]];
并且将UITableView的透明度设置一下就搞定拉。
2、创建UITableViewCell时,的模式用UITableViewCellStyleValue1时,透明度直接将UITableView的透明度设置以下就搞定拉,但是文字居中难以实现。
iOS UITableViewCell透明度 和 cell文字居中
最新推荐文章于 2025-07-31 10:19:21 发布
本文介绍如何在创建UITableViewCell时实现文字居中及背景透明度调整。针对UITableViewCellStyleDefault样式,通过设置cell.textAlignment和cell.opaque等属性实现文字居中及背景透明;对于UITableViewCellStyleValue1样式,则主要关注透明度设置。

7542

被折叠的 条评论
为什么被折叠?



