Objective c 如何更改反弹区域';水平UITableView的s颜色/背景
我正在根据开发一个定制的“脉冲式”UITableView,一切都很顺利。我做了一些修改和扩展,但有一个功能我想实现,我需要一些帮助:水平反弹区域的颜色 这是创建包含表视图的单元格的方法:Objective c 如何更改反弹区域';水平UITableView的s颜色/背景,objective-c,ios,uiview,uitableview,Objective C,Ios,Uiview,Uitableview,我正在根据开发一个定制的“脉冲式”UITableView,一切都很顺利。我做了一些修改和扩展,但有一个功能我想实现,我需要一些帮助:水平反弹区域的颜色 这是创建包含表视图的单元格的方法: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *cellIdentifier = [@"TableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellIdentifier = [@"TableViewCell" stringByAppendingFormat:@"%i", self.content.indexInArrayOfViews];
UIView *view = [self.content viewAtIndex:indexPath.row];
UITableViewCell *cell = [self.horizontalTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier] autorelease];
view.center = CGPointMake(view.center.y,view.center.x);
view.contentMode = UIViewContentModeCenter;
view.transform = CGAffineTransformMakeRotation(M_PI_2);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
[cell addSubview:view];
return cell;
}
我知道有一个重用单元的问题,但现在我想改变
我可以控制垂直表视图反弹区域的颜色,但我很难将此成功复制到水平视图
这是我垂直操作的方式:
CGRect frame = self.tableView.bounds;
frame.origin.y = -frame.size.height;
UIView* topBack = [[UIView alloc] initWithFrame:frame];
topBack.backgroundColor = [self.delegate backgroundColorForTopOfTableView];
[self.tableView addSubview:topBack];
[topBack release];
如何更改水平表格视图(嵌套在表格视图单元格中)的颜色/背景?
我发现了一个解决方案:
if (indexPath.row == 0){
UIView *bounce = [[UIView alloc] initWithFrame:CGRectMake(-320, 0, 320, 150)];
bounce.backgroundColor = [self.delegate colorForBounceRegionAtRow:self.content.indexInArrayOfViews];
[view addSubview:bounce];
}
if (indexPath.row + 1 == self.content.viewCount){
UIView *bounce = [[UIView alloc] initWithFrame:CGRectMake([self.content widthOfViewAtIndex:self.content.viewCount - 1], 0, 320*2, [self.content greatestHeight])];
bounce.backgroundColor = [self.delegate colorForBounceRegionAtRow:self.content.indexInArrayOfViews];
[view addSubview:bounce];
}
这会在第一个和最后一个元素中添加一个全屏彩色矩形,给人一种反弹区域的错觉。您是否尝试过在添加到单元格的视图上设置
backgroundColor
属性?没有,我没有,我现在会尝试,但直觉上我看不出为什么会解决这个问题,但我会尝试任何方法:D(不幸的是,这不起作用,下面发布了解决方案。)