iOS8 图像不显示在圆角

标签 ios objective-c uiimageview uiimage calayer

enter image description here

我试图使图像的角变圆,但它没有显示圆形图像。请给我建议。

 self.Image.layer.cornerRadius = self.Image.frame.size.width / 2;
 self.Image.layer.masksToBounds = YES;
 self.Image.layer.borderColor = [UIColor lightGrayColor].CGColor;
 self.Image.layer.borderWidth=2.0;

最佳答案

您的代码运行良好。 ImageView 是圆形的。看到角是圆的。实际上,您使用的图像是“风景”。尝试使用其他图像。或将 imageView 的“Mode”属性更改为scale to fill。您将得到结果。

_imageView.contentMode = UIViewContentModeScaleAspectFill;

使用此代码。

关于iOS8 图像不显示在圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39953099/

相关文章:

ios - NSAssert 与 NSCAssert

iphone - 如何使用从 Web 服务返回的以下数据填充 UIImage?

ios - 屏蔽 UIImageView 需要什么,我如何在 Swift 3 中进行屏蔽?

ios - CCLabelTTF 在 iOS 6.1 中不起作用

ios - 我不断收到有关我的 iOS 项目的 .png 文件的多个构建命令的警告

ios - 由于 UITableView dataSource 必须从 tableView :cellForRowAtIndexPath: in iOS 5. 1 模拟器返回一个单元格,应用程序崩溃

objective-c - 操作无法完成。没有这样的文件或目录: but the file exists

objective-c - iOS:performSelectorOnBackground/MainThread:不更新标签

ios - 当 BOOL var 为真时动态创建 uiimageview

ios - React Native Twitter 登录冲突 fb 和 google 登录 iOS