码迷,mamicode.com
首页 > 其他好文 > 详细

UITableView分隔线

时间:2014-06-06 16:35:16      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

问题1:

在ios中使用UITableView时,当行数较少是,可能一屏幕能显示完全所有行,这时候会出现下面的问题,显示多余的分隔线

图如下:

bubuko.com,布布扣

解决方案:

bubuko.com,布布扣
//解决方案1

//添加如下代码
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}



//解决方案2
//添加如下代码

    UIView* v = [[UIView alloc]init];
    //    v.backgroundColor = [UIColor clearColor];
    //    _tableview.tableFooterView = v;
    self.myTableView.tableFooterView = v;
bubuko.com,布布扣

效果如下

bubuko.com,布布扣

在实现了上面的功能后,我发现在ios7中,分隔符不能完全填充整个UITableView,有了以下解决方案:

    UIEdgeInsets edgeInset = self.myTableView.separatorInset;
    self.myTableView.separatorInset = UIEdgeInsetsMake(edgeInset.top, 0, edgeInset.bottom, edgeInset.right);//修改分隔线长度
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;

效果如下:

bubuko.com,布布扣

 

希望能帮助到遇到同样问题的朋友。

如果你有更好的解决方案,欢迎分享。

UITableView分隔线,布布扣,bubuko.com

UITableView分隔线

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/JuneWang/p/3766399.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!