iOS7中奇怪的UITableViewCell选择

纳扬

我正在iOS7中开发应用程序我有一个TableViewController,它的样式是分组的。我成功实现了解决方案,可以TableView根据需要获得曲线

编辑:-我没有使用任何自定义类的单元格。TableView仅从笔尖添加了默认情况下使用的单元格。

实现的代码如下:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(tintColor)]) {
        if (tableView == self.tblviwSample) {
            CGFloat cornerRadius = 5.f;
            cell.backgroundColor = UIColor.clearColor;
            CAShapeLayer *layer = [[CAShapeLayer alloc] init];
            CGMutablePathRef pathRef = CGPathCreateMutable();
            CGRect bounds = CGRectInset(cell.bounds, 10, 0);
            BOOL addLine = NO;
            if (indexPath.row == 0 && indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
                CGPathAddRoundedRect(pathRef, nil, bounds, cornerRadius, cornerRadius);
            } else if (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;
            } else if (indexPath.row == [tableView numberOfRowsInSection: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 = [UIColor colorWithWhite:1.f alpha:0.8f].CGColor;

            if (addLine == YES) {
                CALayer *lineLayer = [[CALayer alloc] init];
                CGFloat lineHeight = (1.f / [UIScreen mainScreen].scale);
                lineLayer.frame = CGRectMake(CGRectGetMinX(bounds)+10, bounds.size.height-lineHeight, bounds.size.width-10, lineHeight);
                lineLayer.backgroundColor = tableView.separatorColor.CGColor;
                [layer addSublayer:lineLayer];
            }
            UIView *testView = [[UIView alloc] initWithFrame:bounds];
            [testView.layer insertSublayer:layer atIndex:0];
            testView.backgroundColor = UIColor.clearColor;
            cell.backgroundView = testView;
        }
    }
}

该代码的效果-参见-选择之前

但是遇到一个问题,当我选择一个单元格时,看起来像这样奇怪

我想要以适当的方式显示该部分。任何想法将不胜感激。

毫不费力

我可以使tableview变薄(从两侧减小宽度),然后实现外观,以使该行不会在tableview的边缘之前结束,而是一直延伸到tableview的一侧。

换句话说-减小表格视图的宽度以匹配当前的线宽,并使该线保持为现在的出价(然后该线将与表格视图一样宽)。您的选择范围也将减少。

或者,根据选择,您可以修改表格视图单元格,以便模仿某些自定义选择。这可能是从更改单元格颜色到通过动画翻转单元格颜色。

希望能有所帮助。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

UITableViewCell indexPath在iOS7中崩溃

来自分类Dev

iOS7的UIScrollView中奇怪的contentSize

来自分类Dev

UITableViewCell drawInRect iOS7

来自分类Dev

在嵌入在UITableviewCell(ios7)中的UITableView中滚动

来自分类常见问题

UITableViewCell中的iOS7上的自动布局约束问题

来自分类Dev

在UITableViewCell iOS7中搜索超级视图

来自分类Dev

UITableViewCell子视图在iOS7中仅返回UITableViewCellScrollView

来自分类Dev

UITableViewCell子视图在iOS7中仅返回UITableViewCellScrollView

来自分类Dev

iOS7中UIActionSheet旁边的奇怪工件

来自分类Dev

如何使文本适合iOS7的UITableViewCell?

来自分类Dev

如何使文本适合iOS7的UITableViewCell?

来自分类Dev

UITableViewCell AccessoryViews在iOS6中不显示,但在iOS7中显示

来自分类Dev

设置UITableViewCell backgroundView和selectedBackgroundView在iOS7中不起作用

来自分类Dev

ios7中的UITableViewCell现在在左右之间有空隙

来自分类Dev

在iOS7中处于编辑模式时,更改uitableviewcell“删除”部分的颜色

来自分类Dev

iOS7:其子视图之一中的UITableViewCell

来自分类Dev

如何在UITableViewCell的背景中实现实时iOS7模糊效果

来自分类Dev

在iOS7中处于编辑模式时,UITableViewCell内容与删除按钮重叠

来自分类Dev

在iOS7中处于编辑模式时,更改uitableviewcell“删除”部分的颜色

来自分类Dev

iOS7中奇怪的UITabBar颜色不一致

来自分类Dev

iOS6与iOS7,UITableViewCell滑动删除问题

来自分类Dev

iOS7中的UIVisualEffectView

来自分类Dev

iOS7中的UIPopoverViewController?

来自分类Dev

iOS7中的tableview

来自分类Dev

iOS7中的UIVisualEffectView

来自分类Dev

ios7 UITableViewCell selectionStyle不会变回蓝色

来自分类Dev

UITableViewCell无法正确提交编辑样式[iOS7]

来自分类Dev

UITableViewCell在ios7之前无法正确显示

来自分类Dev

ios7 Storybaoard UITableViewCell不适用于表

Related 相关文章

  1. 1

    UITableViewCell indexPath在iOS7中崩溃

  2. 2

    iOS7的UIScrollView中奇怪的contentSize

  3. 3

    UITableViewCell drawInRect iOS7

  4. 4

    在嵌入在UITableviewCell(ios7)中的UITableView中滚动

  5. 5

    UITableViewCell中的iOS7上的自动布局约束问题

  6. 6

    在UITableViewCell iOS7中搜索超级视图

  7. 7

    UITableViewCell子视图在iOS7中仅返回UITableViewCellScrollView

  8. 8

    UITableViewCell子视图在iOS7中仅返回UITableViewCellScrollView

  9. 9

    iOS7中UIActionSheet旁边的奇怪工件

  10. 10

    如何使文本适合iOS7的UITableViewCell?

  11. 11

    如何使文本适合iOS7的UITableViewCell?

  12. 12

    UITableViewCell AccessoryViews在iOS6中不显示,但在iOS7中显示

  13. 13

    设置UITableViewCell backgroundView和selectedBackgroundView在iOS7中不起作用

  14. 14

    ios7中的UITableViewCell现在在左右之间有空隙

  15. 15

    在iOS7中处于编辑模式时,更改uitableviewcell“删除”部分的颜色

  16. 16

    iOS7:其子视图之一中的UITableViewCell

  17. 17

    如何在UITableViewCell的背景中实现实时iOS7模糊效果

  18. 18

    在iOS7中处于编辑模式时,UITableViewCell内容与删除按钮重叠

  19. 19

    在iOS7中处于编辑模式时,更改uitableviewcell“删除”部分的颜色

  20. 20

    iOS7中奇怪的UITabBar颜色不一致

  21. 21

    iOS6与iOS7,UITableViewCell滑动删除问题

  22. 22

    iOS7中的UIVisualEffectView

  23. 23

    iOS7中的UIPopoverViewController?

  24. 24

    iOS7中的tableview

  25. 25

    iOS7中的UIVisualEffectView

  26. 26

    ios7 UITableViewCell selectionStyle不会变回蓝色

  27. 27

    UITableViewCell无法正确提交编辑样式[iOS7]

  28. 28

    UITableViewCell在ios7之前无法正确显示

  29. 29

    ios7 Storybaoard UITableViewCell不适用于表

热门标签

归档