如何解决iPhone UIGroupTableView-如何隐藏单元格边框,但如何保留部分的圆形边框
|| 当我设定tableView.separatorColor = [UIColor clearColor]
它也隐藏了部分边框。
任何想法,我如何隐藏所有单元格分隔符边框,但整个部分的圆形边框都应该存在。
我已经尝试过了,它可以以某种方式起作用,但是即使我叫[cell setNeedsdisplay]
,也不会刷新。如果我滚动,则内容重绘。
UIView *bgView = [[UIView alloc] initWithFrame: CGRectMake(cell.frame.origin.x +10,-1,cell.frame.size.width - 20,cell.frame.size.height + 1)];
bgView.backgroundColor = [UIColor whiteColor];
[cell addSubview: bgView];
[cell sendSubviewToBack:bgView];
cell.clipsToBounds = NO;
[bgView release];
[cell setNeedsdisplay];
解决方法
尝试使用
UITableView
的spacerStyle属性。
@property(nonatomic) UITableViewCellSeparatorStyle separatorStyle
可能的类型是
UITableViewCellSeparatorStyleNone,UITableViewCellSeparatorStyleSingleLine,UITableViewCellSeparatorStyleSingleLineEtched
, 由于我只有一个单元格,因此请在一个单元格中绘制可变数量的单元格作为UILabel。现在解决问题!
// Create a cell with dynamic number of elements looking like UITableViewCellStyleValue2
- (UITableViewCell *) createDynamicCell {
static NSString *CellIdentifier = @\"Cell\";
UITableViewCell *cell;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
cell.clipsToBounds = NO;
// change frame of one or more labels
CGRect cellFrame = self.tableView.frame;
CGFloat startY = 5.0,startX = 10.0,extra1 = 20.0,gap = 10.0,startX2 = 0.0;
UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(startX + 5,startY,300 - startX * 2,44)];
if (costBreakupStyle == CostBreakupDepartment) {
headerLabel.text = NSLocalizedString(@\"Cost per department:\",@\"\");
} else {
headerLabel.text = NSLocalizedString(@\"Amount spent per airline:\",@\"\");
}
headerLabel.font = [UIFont boldSystemFontOfSize:17];
[cell addSubview:headerLabel];
[headerLabel release];
startY = startY + 44 + 10;
float mid = (cellFrame.size.width - startX * 2 ) / 2;
startX2 = startX + extra1 + mid + gap;
for (int i = 0; i < [dataSource count]; i++ ) {
startY += 5; // cell gap
NSString *text = [dataSource objectAtIndex:i];
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(startX,mid + extra1,kThinnerRowHeight)];
textLabel.text = [NSString stringWithFormat:@\"%@:\",text];
float cost = [(NSNumber *) [costArray objectAtIndex:i] floatValue];
NSString *detailText = [NSString stringWithFormat:@\"%@ %.2f\",[[Settings getInstance] getCurrencyCode],cost];
UILabel *detailTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(startX2,mid - extra1 - gap,kThinnerRowHeight)];
detailTextLabel.text = detailText;
textLabel.font = [UIFont systemFontOfSize:15.0];
textLabel.textAlignment = UITextAlignmentRight;
detailTextLabel.font = [UIFont systemFontOfSize:15.0];
detailTextLabel.textAlignment = UITextAlignmentLeft;
detailTextLabel.textColor = [UIColor blueColor];
[cell addSubview:textLabel];
[cell addSubview:detailTextLabel];
[textLabel release];
[detailTextLabel release];
startY += kThinnerRowHeight;
}
// Total amount label
startY += 15; // add a gap
NSString *text = NSLocalizedString(@\"Total amount spent:\",@\"\");
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(startX,mid + 20,kThinnerRowHeight)];
textLabel.text = text;
UILabel *detailTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(startX2,kThinnerRowHeight)];
detailTextLabel.text = [NSString stringWithFormat:@\"%@ %.2f\",[[RequestResources getInstance] totalCredit]];
textLabel.font = [UIFont systemFontOfSize:15.0];
textLabel.textAlignment = UITextAlignmentRight;
detailTextLabel.font = [UIFont systemFontOfSize:15.0];
detailTextLabel.textAlignment = UITextAlignmentLeft;
detailTextLabel.textColor = [UIColor blueColor];
[cell addSubview:textLabel];
[cell addSubview:detailTextLabel];
[textLabel release];
[detailTextLabel release];
// Credit remaining label
startY += kThinnerRowHeight;
text = NSLocalizedString(@\"Total credit remaining:\",@\"\");
textLabel = [[UILabel alloc] initWithFrame:CGRectMake(startX,kThinnerRowHeight)];
textLabel.text = text;
detailTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(startX2,[[RequestResources getInstance] remainingCredit]];
textLabel.font = [UIFont systemFontOfSize:15.0];
textLabel.textAlignment = UITextAlignmentRight;
detailTextLabel.font = [UIFont systemFontOfSize:15.0];
detailTextLabel.textAlignment = UITextAlignmentLeft;
detailTextLabel.textColor = [UIColor blueColor];
[cell addSubview:textLabel];
[cell addSubview:detailTextLabel];
[textLabel release];
[detailTextLabel release];
cellHeight = startY + kThinnerRowHeight + 10;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。