开发者社区> 问答> 正文

修改 Cell.TextLabel 宽度

我要修改textlabel的cell宽度。因为它和我的按钮重叠了/

代码如下,但是这样删除了cell分割线:

@interface CustomTableViewCell : UITableViewCell
@end

@implementation CustomTableViewCell

- (void)layoutSubviews
{
    CGRect textLabelFrame = self.textLabel.frame;

    textLabelFrame.size.width=250.0f;
    self.textLabel.frame = textLabelFrame;
}

展开
收起
爵霸 2016-03-17 11:24:42 2694 0
1 条回答
写回答
取消 提交回答
  • 如果你用系统cell的 detailtext 貌似是不能设置位置的,他就是固定的位置。 你得自己用一个 继承于 UITableViewCell 的类,来写自己的cell 然后在 那个 -(UITableViewCell *)table……………… (UITableView 的delegate这个方法中) { static NSString *…………; UITableViewCell *cell = ………………; //这里的 UITableViewCell 换成你自己写的cell if (nil == cell) cell = [UITableViewCell alloc]init ………………; //这里的 UITableViewCell 也换成你自己写的cell //后面不变 } 你自定制之后,自己设置detailtext

    答案来源于网络

    2019-09-30 14:31:40
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载