tableview cell 间隙,

作者: 失忆的程序员 | 来源:发表于2020-03-31 10:56 被阅读0次

不多说 ,直接上代码,效果自己粘贴项目里自己尝试。

/*
 *  通过重写frame,设置cell的样式
 **/
- (void)setFrame:(CGRect)frame
{
    // 设置cell在tableview中的x坐标,与左边框距离+10
    frame.origin.x = 10;
    // 设置cell在tableview中的y坐标,每个cell依次+10
    frame.origin.y += 10;
    // cell高度整体-20,效果:cell两边距离屏幕10
    frame.size.width -= 20;
    // cell高度整体-10,效果:cell上下间隙10
    frame.size.height -= 10;
    // 重写父类方法x
    [super setFrame:frame];
}

相关文章

网友评论

    本文标题:tableview cell 间隙,

    本文链接:https://www.haomeiwen.com/subject/itxwuhtx.html