cell里面 self 和self.contentview的区别

    xiaoxiao2025-08-08  9

    一般我们向cell中添加子视图,有两种方式

    [cpp]  view plain  copy  print ? 1、[cell addSubview:]   [cpp]  view plain  copy  print ? 2、[cell.contentView addSubview:]  

        区别在于进行cell编辑时,比如cell内容向左移或者右移时,第一种方式子视图不会移动,第二可以,所以这种情况一般使用第二种方式。

        还有在设置backgroundColor时,使用cell设置时左移或者右移颜色是不会变的,而用cell.contentCell设置时,移动后的空白会显示cell的默认颜色,这种情况视实际情况选择。

        其实这两种方式在大多数情况是一样,不用纠结。

    本文转载自:http://blog.csdn.net/cos_sin_tan/article/details/50832753

    转载请注明原文地址: https://ju.6miu.com/read-1301543.html
    最新回复(0)