【问题标题】:Drawing on a UITableViewCell backgroundView using CoreGraphics使用 CoreGraphics 在 UITableViewCell backgroundView 上绘图
【发布时间】:2013-05-09 19:14:04
【问题描述】:

我有一个 UITableViewCell 的子类,我需要在其中为单元格绘制自定义背景视图。实现drawRect:,我可以很好地绘制视图,但它在tableView和tableViewCells后面。

为了使用 CG 来绘制我的自定义 backgroundView,我是否需要创建一个单独的 UIView 子类来进行绘制并将其设置为单元格的 backgroundView?

谢谢!

编辑:截图

我希望绘制蓝色而不是白色。代替白色。或者至少在它之上。

我正在使用 CA 在单元格后面绘制阴影,我希望在我正在绘制的视图后面有这个阴影。

【问题讨论】:

  • 显示屏幕截图,以便我们了解发生了什么。

标签: iphone ios uitableview drawing core-graphics


【解决方案1】:

你需要设置 contentView 的背景。

myCell.contentView.backgroundColor = [ UIColor greenColor ]; // 

【讨论】:

    【解决方案2】:

    试试这个,

    cell.contentView.backgroundColor = [UIColor clearColor];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-03
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 2020-05-31
      • 2011-11-12
      相关资源
      最近更新 更多