Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何更改反弹区域';水平UITableView的s颜色/背景_Objective C_Ios_Uiview_Uitableview - Fatal编程技术网

Objective c 如何更改反弹区域';水平UITableView的s颜色/背景

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

我正在根据开发一个定制的“脉冲式”UITableView,一切都很顺利。我做了一些修改和扩展,但有一个功能我想实现,我需要一些帮助:水平反弹区域的颜色

这是创建包含表视图的单元格的方法:

- (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(不幸的是,这不起作用,下面发布了解决方案。)