【发布时间】:2023-03-28 21:15:01
【问题描述】:
我使用UIBezierPath 实现了一个非常简单的填充圆圈,然后我将其转换为UIImage,这样我就可以将其设置为UITableViewCell 的imageView。这非常有效,但您可以在 Retina 显示屏上看到边缘像素化。为什么会这样,可以做些什么来确保它看起来很棒?
let colorSize = cell.frame.size.height - 20
let rect = CGRectMake(0, 0, colorSize, colorSize)
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()
UIBezierPath(roundedRect: rect, cornerRadius: (colorSize)/2).addClip()
CGContextSetFillColorWithColor(context, UIColor.redColor().CGColor);
CGContextFillRect(context, rect)
var colorImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
cell.imageView?.image = colorImage
【问题讨论】:
标签: ios swift uiimage cgcontext uibezierpath