1

我正在尝试通过 UIAppearance 以与实现自定义 UINavigationBar (ruby 运动语法)相同的方式对 UITableViewCell 进行自定义:

bg = UIImage.imageNamed("cell_bg.png").resizableImageWithCapInsets(UIEdgeInsetsMake(0,13,0,13))
UITableViewCell.appearance.setBackgroundImage(bg, forState:UIControlStateNormal, barMetrics:UIBarMetricsDefault)

但是 setBackgroundImage 没有定义, setBackgroundView 也没有 setBackgroundViewImage ... UITableViewCell 符合 UIAppearanceContainer ,所以我不应该能够使用其中之一吗?

谢谢

4

1 回答 1

2

符合 UIAppearanceContainer 并不意味着你可以设置任何你喜欢的外观,它只是意味着它会提供一个外观代理。据我所知, UITableViewCell 没有任何内置的 UIAppearance 方法。

根据您的需要,尝试使用可拉伸图像创建 UIImageView,并将其设置为backgroundView单元格的。

于 2012-06-11T16:21:15.193 回答