Ric*_*evy 2 iphone cocoa-touch uitableview uiimageview
如果我在我的UITableViewCell子类的init方法中为我的表格单元格创建一个背景图像,那么图像就是我绘制它的方式,并且tableView:heightForRowAtIndexPath:只是在它周围增加了一个间隙.
但是,如果我在tableView的tableView:cellForRowAtIndexPath:方法中创建背景图像并进行设置,则更改单元格高度现在将拉伸图像.
我需要在cellForRowAtIndexPath方法中创建背景视图,因为不同行的背景会发生变化.如何才能使图像的大小再次固定?
您是否尝试将contentMode设置为UIViewContentModeCenter以获取单元格的backgroundView?
放在这里
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundView.contentMode = UIViewContentModeCenter;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1113 次 |
| 最近记录: |