gpt4 book ai didi

ios - 创建一个圆形的 TableViewCell 指示器,就像 Apple Mail 应用程序一样

转载 作者:搜寻专家 更新时间:2023-10-31 22:03:14 24 4
gpt4 key购买 nike

当电子邮件被标记为未读时,我正在尝试为我的 TableViewCell 创建一个类似于 Apple Mail 应用程序中的圆形指示器。

enter sdsdsdsd description

我有以下代码:

var Indicator = CAShapeLayer()
var IndicatorSize: CGFloat = 10

// standard blue color
let blueColor = UIColor(red: 0, green: 122.0/255.0, blue:1.0, alpha:1)

// create circular CAShapeLayer
Indicator.bounds = CGRect(x:0, y:0, width:IndicatorSize, height:IndicatorSize)
Indicator.position = CGPoint(x: 10, y: 10)
Indicator.cornerRadius = Indicator.frame.size.width/2

// add as cell sublayer
cell.layer.addSublayer(Indicator)

虽然这似乎可以完成工作,但感觉圆圈不如邮件应用程序中的圆圈光滑,角落看起来几乎像素化。我不确定这是不是因为我正在使用 CAShapeLayer。我想知道是否有更好的选择。

我还可以将它作为单元格的对象而不仅仅是一个层,以便我可以使用 cell.Indicator 调用它吗?

最佳答案

class CircleView: UIView {
override func drawRect(rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
self.tintColor.setFill()
CGContextFillEllipseInRect(context, rect)
}
}

关于ios - 创建一个圆形的 TableViewCell 指示器,就像 Apple Mail 应用程序一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30604341/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com