CircleBar icon indicating copy to clipboard operation
CircleBar copied to clipboard

Unable to change Tint Colour,Background Image and other layer properties.

Open developerawais1 opened this issue 5 years ago • 2 comments

I'm unable to change layer properties from storyboard.

developerawais1 avatar Dec 17 '19 10:12 developerawais1

I'm unable to change layer properties from storyboard.

You need to change the class with this

image?.withRenderingMode(.alwaysTemplate)
UIColor.white.set() 

or the color that you want

private func image(with image: UIImage?, scaledTo newSize: CGSize) -> UIImage? {
image?.withRenderingMode(.alwaysTemplate)
UIGraphicsBeginImageContextWithOptions(newSize, _: false, _: 0.0)
UIColor.white.set()
image?.draw(in: CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height))
let newImage: UIImage? = UIGraphicsGetImageFromCurrentImageContext()

UIGraphicsEndImageContext()

return newImage
}

carlos0193 avatar Jan 25 '21 20:01 carlos0193

on SCHCircleBar

     let fillColor: UIColor = UIColor.black

you need to set color to backGounr

    override func draw(_ rect: CGRect) {
    let fillColor: UIColor = UIColor.black
    tabWidth = self.bounds.width / CGFloat(self.items!.count)
    let bezPath = drawPath(for: index)
    bezPath.close()
    fillColor.setFill()
    bezPath.fill()
    let mask = CAShapeLayer()
    mask.fillRule = .evenOdd
    mask.fillColor = fillColor.cgColor
    mask.path = bezPath.cgPath
    if (self.animated) {
        let bezAnimation = CABasicAnimation(keyPath: "path")
        let bezPathFrom = drawPath(for: previousIndex)
        bezAnimation.toValue = bezPath.cgPath
        bezAnimation.fromValue = bezPathFrom.cgPath
        bezAnimation.duration = 0.3
        bezAnimation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
        
        mask.add(bezAnimation, forKey: nil)
    }
    self.layer.mask = mask
}

carlos0193 avatar Jan 25 '21 20:01 carlos0193