         dotView.layer.cornerRadius = dotView.bounds.size.width * 0.5
         countLabel.frame = imageView.frame
     }
+    
+    override var frame: CGRect {
+        didSet {
+           updateLayout()
+        }
+    }
+    
+    override var bounds: CGRect {
+        didSet {
+            updateLayout()
+        }
+    }
 }

        }
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        selectedImageView.frame = bounds
        selectedImageView.layer.cornerRadius = selectedImageView.bounds.size.width * 0.5
        
        imageView.bounds = CGRect(x: 0, y: 0, width: groupDimension, height: groupDimension)
        imageView.center = CGPoint(x: 0.5*bounds.size.width, y: 0.5*bounds.size.height)
        imageView.layer.cornerRadius = imageView.bounds.size.width * 0.5
        
        if countLabel.text != nil {
            imageView.isHidden = true
            dotView.bounds = CGRect(x: 0, y: 0, width: groupDimension, height: groupDimension)

        set(alwaysShowImage: false, animated: false)
        selectedImageView.alpha = 0
        selectedImageView.transform = CGAffineTransform.identity
        dotView.transform = CGAffineTransform.identity
        dotView.alpha = 1
        imageView.alpha = 0
        imageView.transform = CGAffineTransform.identity
        alpha = 1
