ios - 为非方形UIImage添加边框

标签 ios uiimage border

我尝试使用layer.borderColorCGContextSetStrokeColorWithColor在非方形png图像周围添加边框,但这导致图像周围的方形边框不在真实图像周围。

有没有办法做到这一点 ?

最佳答案

如果要舍入的ImageView。

UIImageView *imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@""]];
imageView.layer.borderColor = [UIColor blackColor].CGColor; // Apply Color of your choice
imageView.layer.borderWidth = 2.0;  // Apply width of your choice
imageView.layer.cornerRadius = 50; // Apply radius of your choice
imageView.clipsToBounds = YES;

关于ios - 为非方形UIImage添加边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28136230/

相关文章:

ios - 如何忽略一系列 NSString 中的空字符串值

CSS 边框渲染

border - 如何使用 CSS 边框属性制作五 Angular 星

ios - iOS 中未正确创建 Zip 文件

ios - 使用核心动画后如何获取 View 的当前旋转?

swift - 在开始时创建数百个 UIImage 并让它们在 Swift 中的任何位置可用的最佳方法是什么?

ios - 将 UIBezierPath 转换为 UIImage

css - 如何使用 CSS 制作 3D 按钮?

ios - 从 Swift 中的 URL 中删除所有路径组件

ios - xcode 10 迁移错误获取段错误 11