I'm use extension of button for implements my own method to the UIButton, and the create a CATextLayer for add 1 more text in button, but where im call this method with different arguments (Text) previous text still behind new text and over and over. I need to repaint my button without stack texts (call method with new text and there gonna be only new text)
extension UIButton{
func spordAcceptButAction(c_one: UIColor, c_two: UIColor, corner: Int, w: Int, number: Int, gradientLayer:CAGradientLayer){
var textLayer: CATextLayer!
let startFontSize: CGFloat = 60
let startPosition: CGPoint = CGPoint(x: 0, y: 0)
// Do any additional setup after loading the view, typically from a nib.
// let gradientLayer = CAGradientLayer()
textLayer = CATextLayer()
textLayer.alignmentMode = CATextLayerAlignmentMode.left
textLayer.anchorPoint = CGPoint(x: 0, y: 0)
textLayer.bounds.size = CGSize(width: 100, height: 100)
textLayer.contentsScale = UIScreen.main.scale
textLayer.font = UIFont.systemFont(ofSize: startFontSize, weight: UIFont.Weight.semibold)
textLayer.fontSize = startFontSize
// textLayer.backgroundColor = #colorLiteral(red: 0.521568656, green: 0.1098039225, blue: 0.05098039284, alpha: 1)
textLayer.isWrapped = true
textLayer.position = startPosition
textLayer.string = String(number)