Друзья, подскажите, как правильно реализовать градиент в ячейки, поскольку при текущей реализации и большой таблице видно некоторое замеделение
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! FeedTableViewCell
dispQueueGlobUtility.async {
var title = self.userNameArray[indexPath.row]
title.capitalizeFirstLetter()
let url = URL(string: self.proPicUrlArray[indexPath.row])
let id = self.userIdArray[indexPath.row]
DispatchQueue.main.async {
cell.userName.text = title
cell.profileImageView.sd_setImage(with: url, completed: nil)
cell.profileImageView.contentMode = .scaleAspectFill
cell.userId.text = id
cell.userPic = self.proPicUrlArray[indexPath.row]
let gradientLayer: CAGradientLayer = CAGradientLayer()
let shapeLayer = CAShapeLayer()
let startColor: UIColor = UIColor(red: 0.78, green: 0.18, blue: 0.56, alpha: 1.0)
let endColor: UIColor = UIColor(red: 0.98, green: 0.62, blue: 0.30, alpha: 1.0)
let gradientColors: [CGColor] = [startColor.cgColor, endColor.cgColor]
gradientLayer.calculatePoints(for: 110)
gradientLayer.frame = CGRect(x: -0.1, y: 0, width: cell.profileImageView.frame.width, height: cell.profileImageView.frame.height)
gradientLayer.colors = gradientColors
let lineWidth: CGFloat = 2
let maskPath = UIBezierPath(roundedRect: cell.profileImageView.bounds.insetBy(dx: lineWidth/2, dy: lineWidth/2), byRoundingCorners: [.allCorners], cornerRadii: CGSize(width: cell.profileImageView.frame.width/2, height: cell.profileImageView.frame.height/2)).cgPath
shapeLayer.lineWidth = 2
shapeLayer.path = maskPath
shapeLayer.strokeColor = UIColor.black.cgColor
shapeLayer.fillColor = UIColor.clear.cgColor
gradientLayer.mask = shapeLayer
cell.profileImageView.layer.insertSublayer(gradientLayer, at: 1)
}
}
return cell
}