Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let font = UIFont.systemFont(ofSize: 12)
- let attributes = [
- NSAttributedString.Key.font: UIConstants.CaptionFont,
- NSAttributedString.Key.foregroundColor: UIColor.accent
- ]
- for path in pathsForIndicators {
- let cgPath = path.cgPath
- let layer = CATextLayer()
- layer.frame = CGRect(x: cgPath.boundingBox.midX + offset + 22,
- y: cgPath.boundingBox.midX + 10, width: 40, height: 40)
- layer.position = CGPoint(x: cgPath.boundingBox.midX + offset + 22,
- y: cgPath.boundingBox.midY + 10)
- layer.font = font
- let value = 0 // TODO
- let title = String(describing: value)
- let attributedString = NSAttributedString(string: title, attributes: attributes)
- layer.string = attributedString
- layer.isWrapped = false
- layer.alignmentMode = CATextLayerAlignmentMode.center
- layer.foregroundColor = indicatorColor.cgColor
- layer.shouldRasterize = true
- layer.needsDisplayOnBoundsChange = false
- layer.needsDisplay()
- layer.displayIfNeeded()
- textLayer.addSublayer(layer)
- }
- textLayer.backgroundColor = UIColor.clear.cgColor
- textLayer.bounds = bounds
- textLayer.position = centerPoint
- layer.addSublayer(textLayer)
Add Comment
Please, Sign In to add comment