Hello, I have a one problem.
I have one storyBoard on which collection view.
Cell of Collection View have a UIView.
And later in code I'm add circle on this view, but with time all circles, but first and last is disappeared.
May be somebody can help me.
I from Russia, about my English is soooo bad :)
Look at code of my collection view cell:
import UIKit
class CustomCollectionViewCell: UICollectionViewCell {
static let cellID = "CustomCell"
@IBOutlet weak var BackGroundView: UIView!
var circle : CAShapeLayer? = nil
var cellcreate : CellModel? {
didSet {
self.UpdateUI()
}
}
private func UpdateUI () {
if let cellcreate = cellcreate {
BackGroundView.backgroundColor = cellcreate.color
print("Hello")
} else {
BackGroundView.backgroundColor = UIColor.white
}
}
override func layoutSubviews() {
super.layoutSubviews()
layer.cornerRadius = 15
layer.shadowRadius = 10
layer.shadowOpacity = 0.3
layer.shadowOffset = CGSize(width: 5, height: 10)
BackGroundView.clipsToBounds = true
BackGroundView.layer.cornerRadius = 15
self.clipsToBounds = false
if circle == nil {
circle = CAShapeLayer()
let center = contentView.center
let cir = UIBezierPath(arcCenter: center, radius: 20, startAngle: 0, endAngle: 2*CGFloat.pi, clockwise: true)
circle?.path = cir.cgPath
}
BackGroundView.layer.addSublayer(circle!)
}
}