2

以下是我从 App Store 的应用程序中获取的图像:

UITableViewCell

我创建了一个使用 StoryBoard 和自定义 tableview 单元格的应用程序。数据是从 Web 服务加载到其中的。这就是我要的:

1)如何根据图像更改uitableviewcell的大小?例如,如果一张图片是 640*500,那么 UITableViewCell 会相应地改变它的大小。如果图像的大小为 640*1000,则单元格应相应更改其大小。

2)我怎样才能像上图一样在表格视图单元格周围添加灰色边框?

3)我怎样才能像上图一样添加从 UITableViewCell 掉落的阴影?

谢谢!

4

2 回答 2

1

Currently i have a partial answer to your question. Part 2 of the question that is the colored border can be solved by the following code:

[cell.contentView.layer setBorderColor:[UIColor colorWithRed:222/255.0f green:222/255.0f blue:222/255.0f alpha:1.0f].CGColor];
[cell.contentView.layer setBorderWidth:5.0f];
于 2013-10-17T16:27:44.280 回答
0

第 1 部分 tableviewcell 的高度由使用确定

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   /*
    Get the image size 
    CGFloat width = myImage.size.width;
    CGFloat height = myImage.size.height;
    use this to return the height of your cell. 
   */
}

第 2 部分和第 3 部分使用..

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

   //This will give you access to the cell being rendered and any customization you want can be done here... You can use the earlier answer for this part.. I havent tried it but should work..
}

希望这可以帮助..

于 2013-10-17T16:55:09.460 回答