UITableViewCell有方角的图像 [英] UITableViewCell has square corner with image

查看:80
本文介绍了UITableViewCell有方角的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分组 UITableView ,其中包含几个单元格(只是标准 UITableViewCell UITableViewCellStyleSubtitle 样式。 Bueno。然而,当我插入图像(使用提供的 imageView 属性),左侧的角落变成方形。

I have a grouped UITableView that contains several cells (just standard UITableViewCells), all of which are of UITableViewCellStyleSubtitle style. Bueno. However, when I insert images into them (using the provided imageView property), the corners on the left side become square.

用于分配的代码进入单元格的值为:

The code being used to assign the values into the cell is:

cell.textLabel.text = currentArticle.descriptorAndTypeAndDifferentiator;
cell.detailTextLabel.text = currentArticle.stateAndDaysWorn;
cell.imageView.image = currentArticle.picture;

currentArticle.picture c $ c> UIImage (也可以看到,除了正方形角之外,图片也很好)。

and currentArticle.picture is a UIImage (also the pictures, as you can see, display just fine with the exception of the square corners).

在我的iPhone 3G,iPhone 4模拟器和iPad模拟器上显示相同。

It displays the same on my iPhone 3G, in the iPhone 4 simulator and in the iPad simulator.

我要做的是类似于

What I'm going for is something similar to the UITableViewCells that Apple uses in its iTunes app.

我在做什么错误的任何想法?

Any ideas about what I'm doing wrong?

感谢,

-Aaron

Thanks,
-Aaron

推荐答案

cell.imageView.layer.cornerRadius = 16; // 16 is just a guess
cell.imageView.clipsToBounds = YES;

这将绕过UIImageView,因此不会覆盖单元格。

This will round the UIImageView so it does not draw over the cell. It will also round all the corners of all your images, but that may be OK.

否则,你必须添加你自己的图像视图,它将只是围绕一个角。你可以通过在调用super之前在drawRect:中设置一个剪辑区域来实现。或者只是添加您自己的图像视图,不是那么接近左边缘。

Otherwise, you will have to add your own image view that will just round the one corner. You can do that by setting up a clip region in drawRect: before calling super. Or just add your own image view that is not so close to the left edge.

这篇关于UITableViewCell有方角的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆