Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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
Ios UITableView重叠单元格(强制)_Ios_Objective C_Uitableview_Calayer - Fatal编程技术网

Ios UITableView重叠单元格(强制)

Ios UITableView重叠单元格(强制),ios,objective-c,uitableview,calayer,Ios,Objective C,Uitableview,Calayer,我希望实现表视图单元格重叠,因为我希望实现此效果: 所以基本上细胞会一个接一个的堆叠起来。我的目标是iOS7+(目前正在使用iOS8进行测试) 我目前正在做一个CAGradientLayer,它位于layoutSubviews中。我将其定位为: CGRect gradientLayerFrame = self.contentView.bounds; gradientLayerFrame.origin.y = -6.0f; gradientLayerFrame.size.height += 6.

我希望实现表视图单元格重叠,因为我希望实现此效果:

所以基本上细胞会一个接一个的堆叠起来。我的目标是iOS7+(目前正在使用iOS8进行测试)

我目前正在做一个
CAGradientLayer
,它位于
layoutSubviews
中。我将其定位为:

CGRect gradientLayerFrame = self.contentView.bounds;
gradientLayerFrame.origin.y = -6.0f;
gradientLayerFrame.size.height += 6.0f;
self.gradientLayer.frame = gradientLayerFrame;
我也做了

self.clipsToBounds = NO;
self.contentView.clipsToBounds = NO;
self.contentView.superview.clipsToBounds = NO;
init
中,这样就不会有任何剪辑。现在,单元格在第一次渲染时会进行剪辑,但当我向下滚动表格视图,然后再向上滚动表格视图,以便再次显示单元格时,它们不会被剪辑

我已经尝试过将
backgroundColor
设置为在
willDisplayCell
中清除,但没有成功。还尝试递归遍历所有单元格子视图,并将“剪裁”设置为“否”,但再次重复相同的操作。还尝试了黑客攻击,并强制设置
setNeedsDisplay
,以便重新渲染,但没有运气


在此问题上的任何帮助都将不胜感激。

它不应该是TableView


尝试此库:

它不应该是TableView


尝试此库:

它不应该是TableView


尝试此库:

它不应该是TableView


试试这个库:

我以前也遇到过同样的问题

对我有效的解决方案是使用集合视图而不是表视图。通过从UICollectionViewFlowLayout扩展自定义类来创建自定义类,并在集合视图中使用它

class OverlappedCustomFlowLayout: UICollectionViewFlowLayout {
    override func prepare() {
        super.prepare()

        // This allows us to make intersection and overlapping
        // A negative number implies overlapping whereas positive implies space between the adjacent edges of two cells.
        minimumLineSpacing = -100
    }

    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
        let layoutAttributes = super.layoutAttributesForElements(in: rect)
        for currentLayoutAttributes: UICollectionViewLayoutAttributes in layoutAttributes! {

            // zIndex - Specifies the item’s position on the z-axis. 
            // Unlike a layer's zPosition, changing zIndex allows us to change not only layer position, 
            // but tapping/UI interaction logic too as it moves the whole item.
            currentLayoutAttributes.zIndex = currentLayoutAttributes.indexPath.row + 1
        }
    }

    return layoutAttributes
}
附言——根据苹果公司的开发者文件

此属性用于确定项目的前后顺序 在布局期间。索引值较高的项目显示在项目顶部 具有较低的值。具有相同值的项具有未确定的 秩序。此属性的默认值为0


希望有帮助!:)

不久前,我也遇到过同样的问题

对我有效的解决方案是使用集合视图而不是表视图。通过从UICollectionViewFlowLayout扩展自定义类来创建自定义类,并在集合视图中使用它

class OverlappedCustomFlowLayout: UICollectionViewFlowLayout {
    override func prepare() {
        super.prepare()

        // This allows us to make intersection and overlapping
        // A negative number implies overlapping whereas positive implies space between the adjacent edges of two cells.
        minimumLineSpacing = -100
    }

    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
        let layoutAttributes = super.layoutAttributesForElements(in: rect)
        for currentLayoutAttributes: UICollectionViewLayoutAttributes in layoutAttributes! {

            // zIndex - Specifies the item’s position on the z-axis. 
            // Unlike a layer's zPosition, changing zIndex allows us to change not only layer position, 
            // but tapping/UI interaction logic too as it moves the whole item.
            currentLayoutAttributes.zIndex = currentLayoutAttributes.indexPath.row + 1
        }
    }

    return layoutAttributes
}
附言——根据苹果公司的开发者文件

此属性用于确定项目的前后顺序 在布局期间。索引值较高的项目显示在项目顶部 具有较低的值。具有相同值的项具有未确定的 秩序。此属性的默认值为0


希望有帮助!:)

不久前,我也遇到过同样的问题

对我有效的解决方案是使用集合视图而不是表视图。通过从UICollectionViewFlowLayout扩展自定义类来创建自定义类,并在集合视图中使用它

class OverlappedCustomFlowLayout: UICollectionViewFlowLayout {
    override func prepare() {
        super.prepare()

        // This allows us to make intersection and overlapping
        // A negative number implies overlapping whereas positive implies space between the adjacent edges of two cells.
        minimumLineSpacing = -100
    }

    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
        let layoutAttributes = super.layoutAttributesForElements(in: rect)
        for currentLayoutAttributes: UICollectionViewLayoutAttributes in layoutAttributes! {

            // zIndex - Specifies the item’s position on the z-axis. 
            // Unlike a layer's zPosition, changing zIndex allows us to change not only layer position, 
            // but tapping/UI interaction logic too as it moves the whole item.
            currentLayoutAttributes.zIndex = currentLayoutAttributes.indexPath.row + 1
        }
    }

    return layoutAttributes
}
附言——根据苹果公司的开发者文件

此属性用于确定项目的前后顺序 在布局期间。索引值较高的项目显示在项目顶部 具有较低的值。具有相同值的项具有未确定的 秩序。此属性的默认值为0


希望有帮助!:)

不久前,我也遇到过同样的问题

对我有效的解决方案是使用集合视图而不是表视图。通过从UICollectionViewFlowLayout扩展自定义类来创建自定义类,并在集合视图中使用它

class OverlappedCustomFlowLayout: UICollectionViewFlowLayout {
    override func prepare() {
        super.prepare()

        // This allows us to make intersection and overlapping
        // A negative number implies overlapping whereas positive implies space between the adjacent edges of two cells.
        minimumLineSpacing = -100
    }

    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
        let layoutAttributes = super.layoutAttributesForElements(in: rect)
        for currentLayoutAttributes: UICollectionViewLayoutAttributes in layoutAttributes! {

            // zIndex - Specifies the item’s position on the z-axis. 
            // Unlike a layer's zPosition, changing zIndex allows us to change not only layer position, 
            // but tapping/UI interaction logic too as it moves the whole item.
            currentLayoutAttributes.zIndex = currentLayoutAttributes.indexPath.row + 1
        }
    }

    return layoutAttributes
}
附言——根据苹果公司的开发者文件

此属性用于确定项目的前后顺序 在布局期间。索引值较高的项目显示在项目顶部 具有较低的值。具有相同值的项具有未确定的 秩序。此属性的默认值为0


希望有帮助!:)

您是否尝试在类似于
didlayoutsubviews
的位置设置单元格的
clipsToBounds
?在
UIViewController
上是否调用了
viewdlayoutsubviews
?我真的不明白这有什么用。然后我必须遍历表视图的可见单元格并设置剪裁。这似乎有点骇人听闻。这只是一种错觉,这里没有重叠。您是否尝试在类似
didlayoutsubviews
的地方设置单元格的
clipsToBounds
?在
UIViewController
上不是调用了
viewdilayoutsubviews
?我真的不明白这有什么用。然后我必须遍历表视图的可见单元格并设置剪裁。这似乎有点骇人听闻。这只是一种错觉,这里没有重叠。您是否尝试在类似
didlayoutsubviews
的地方设置单元格的
clipsToBounds
?在
UIViewController
上不是调用了
viewdilayoutsubviews
?我真的不明白这有什么用。然后我必须遍历表视图的可见单元格并设置剪裁。这似乎有点骇人听闻。这只是一种错觉,这里没有重叠。您是否尝试在类似
didlayoutsubviews
的地方设置单元格的
clipsToBounds
?在
UIViewController
上不是调用了
viewdilayoutsubviews
?我真的不明白这有什么用。然后我必须遍历表视图的可见单元格并设置剪裁。这似乎有点老套。这只是一种视觉错觉,这里没有重叠。确实如此。当我试图使用表视图进行操作时,我是在对其进行伪黑客攻击。这是正确的方法。我没有足够的时间来实现我的自定义解决方案,也不知道这个库。现在一切正常,只需要再做一些调整。当我试图使用表视图进行操作时,我是在对其进行伪黑客攻击。这是正确的方法。我没有足够的时间来实现我的自定义解决方案,也不知道这个库。现在一切正常,只需要再做一些调整。当我试图使用表视图进行操作时,我是在对其进行伪黑客攻击。这是正确的方法。我没有足够的时间来实现我的自定义解决方案,也不知道这个库。Th