分组样式-样式

分组样式-样式

今天来给大家分享一下关于分组样式-样式的问题,以下是对此问题的归纳整理,让我们一起来看看吧。

分组样式-样式

tableview分组样式每组section之间距离的调整

两个注意点:

1.默认tableview分组样式,每组section有额外头部和尾部间距,如果每组之间的间距一致,可以调整tableview的两个属性sectionHeaderHeight和sectionFooterHeight

2.如果有导航条和tabbar,tableview的内容视图也有自己额外的头部和尾部间距,这两个间距是内边距,是可调整的,内容视图中包含cell控件

要求:

1.tableview的分组样式,每组之间距离很大,特别是第一个cell和导航栏之间的距离,不好看,所以需要调整seciton之间的间距,

2.当UITableView的style为UITableViewStyleGrouped时,section之间默认的距离往往不是我们想要的。那怎么设置呢?我们知道每个section都有自己的header和footer,它们的高度和就是section之间的间距

self.tableView.sectionHeaderHeight = 10;self . table view . section footer height = 10;

则区间距离为20 (10+10),默认为18+18。注意,第一组单元没有头部间距,只有尾部间距。

3.如何调整第一组与导航栏的距离?

分组样式中第一个单元格的默认y值是35。如果间距为10,则必须上移25,但这个移位应该是内容视图的整体移位,tableview的表头内边距要自行调整

。表格视图。content insert = uiedgeinsetsmash(-25,

总结:

如果调整区段之间的距离,两个属性将一起调整;如果整体上移,内边距属性contentInset h/]如何在iOS6中实现TableView的分组样式?

为iOS6实现TableView分组样式:

-(void)tableView:(UITableView*)tableViewwillDisplayCell:(UITableViewCell*)cellforRowAtIndexPath:(NSIndexPath*)indexPath

{

if([cellrespondsToSelector:@selector(tintColor)]){

if(tableView==self.tableView){

CGFloatcornerRadius=5.f;

cell.backgroundColor=UIColor.clearColor;

CAShapeLayer*layer=[[CAShapeLayeralloc]init];

CGMutablePathRefpathRef=CGPathCreateMutable();

CGRectbounds=CGRectInset(cell.bounds,10,0);

BOOLaddLine=NO;

if(indexPath.row==0&&indexPath.row==[tableViewnumberOfRowsInSection:indexPath.section]-1){

CGPathAddRoundedRect(pathRef,nil,bounds,cornerRadius,cornerRadius);

}elseif(indexPath.row==0){

CGPathMoveToPoint(pathRef,nil,CGRectGetMinX(bounds),CGRectGetMaxY(bounds));

CGPathAddArcToPoint(pathRef,nil,CGRectGetMinX(bounds),CGRectGetMinY(bounds),CGRectGetMidX(bounds),CGRectGetMinY(bounds),cornerRadius);

CGPathAddArcToPoint(pathRef,nil,CGRectGetMaxX(bounds),CGRectGetMinY(bounds),CGRectGetMaxX(bounds),CGRectGetMidY(bounds),cornerRadius);

CGPathAddLineToPoint(pathRef,nil,CGRectGetMaxX(bounds),CGRectGetMaxY(bounds));

addLine=YES;

}elseif(indexPath.row==[tableViewnumberOfRowsInSection:indexPath.section]-1){

CGPathMoveToPoint(pathRef,nil,CGRectGetMinX(bounds),CGRectGetMinY(bounds));

CGPathAddArcToPoint(pathRef,nil,CGRectGetMinX(bounds),CGRectGetMaxY(bounds),CGRectGetMidX(bounds),CGRectGetMaxY(bounds),cornerRadius);

CGPathAddArcToPoint(pathRef,nil,CGRectGetMaxX(bounds),CGRectGetMaxY(bounds),CGRectGetMaxX(bounds),CGRectGetMidY(bounds),cornerRadius);

CGPathAddLineToPoint(pathRef,nil,CGRectGetMaxX(bounds),CGRectGetMinY(bounds));

}else{

CGPathAddRect(pathRef,nil,bounds);

addLine=YES;

}

layer.path=pathRef;

CFRelease(pathRef);

layer.fillColor=[UIColorcolorWithWhite:1.falpha:0.8f].CGColor;

if(addLine==YES){

CALayer*lineLayer=[[CALayeralloc]init];

CGFloatlineHeight=(1.f/[UIScreenmainScreen].scale);

lineLayer.frame=CGRectMake(CGRectGetMinX(bounds)+10,bounds.size.height-lineHeight,bounds.size.width-10,lineHeight);

lineLayer.backgroundColor=tableView.separatorColor.CGColor;

[layeraddSublayer:lineLayer];

}

UIView*testView=[[UIViewalloc]initWithFrame:bounds];

[testView.layerinsertSublayer:layeratIndex:0];

testView.backgroundColor=UIColor.clearColor;

cell.backgroundView=testView;

}

}}

以上就是由优质生活领域创作者 嘉文社百科网小编 整理编辑的,如果觉得有帮助欢迎收藏转发~

分享到 :
相关推荐

古代数字1到9-数字易经91代表什么

今天,我想和大家分享一个关于古代数字1到9的问题——易经91代表什么。以下是这个问题...

「达人分享」面包店有面包糠卖吗

一般没有。面包糠多用来制作油炸食品。面包店一般不会使用。一般超市中或网上会有售卖的面...

葫的拼音和组词-葫组词拼音部首

今天和大家分享一下胡的拼音和胡组字的拼音部首。以下是这个问题的总结。让我们来看看。有...

开方函数在excel里怎么输入(开方函数在excel里怎么输入出来)

今天给大家分享一个关于如何在excel中输入根函数的问题(如何在excel中输入根函...

模拟城市4插件(模拟城市4插件支持文件)

今天给大家分享一下模拟城市4插件的知识,同时也讲解一下模拟城市4插件的支持文件。如果...

武汉在哪个省哪个市(武汉在哪个省哪个市哪个县)

今天和大家分享一个关于武汉在哪个省哪个市的问题(武汉在哪个省哪个市哪个县)。以下是这...

耐组词和拼音(耐组词和拼音怎么写)

今天跟大家分享一个关于抗字和拼音的问题(抗字和拼音怎么写)。以下是这个问题的总结。让...

黄土高原地貌(黄土高原地貌特征)

  今天小编给各位分享黄土高原地貌(黄土高原地貌特征),如果能碰巧解决你现在面临的问...