-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to round the corners of the BalloonMarker? #3276
Comments
I just remember someone posted code about this but couldn't find it right now. Please try search. If I was wrong, then you have to draw the rounding thing by yourself. |
open override func draw(context: CGContext, point: CGPoint) {
guard let label = label else { return }
let offset = self.offsetForDrawing(atPoint: point)
let size = self.size
var rect = CGRect(
origin: CGPoint(
x: point.x + offset.x,
y: point.y + offset.y),
size: size)
rect.origin.x -= size.width / 2.0
rect.origin.y -= size.height
context.saveGState()
context.setFillColor(color.cgColor)
if offset.y > 0 {
context.beginPath()
let rect2 = CGRect(x: rect.origin.x, y: rect.origin.y + arrowSize.height, width: rect.size.width, height: rect.size.height - arrowSize.height)
let clipPath = UIBezierPath(roundedRect: rect2, cornerRadius: 5.0).cgPath
context.addPath(clipPath)
context.closePath()
context.fillPath()
// arraow vertex
context.beginPath()
let p1 = CGPoint(x: rect.origin.x + rect.size.width / 2.0 - arrowSize.width / 2.0, y: rect.origin.y + arrowSize.height + 1)
context.move(to: p1)
context.addLine(to: CGPoint(x: p1.x + arrowSize.width, y: p1.y))
context.addLine(to: CGPoint(x: point.x, y: point.y))
context.addLine(to: p1)
context.fillPath()
} else {
context.beginPath()
let rect2 = CGRect(x: rect.origin.x, y: rect.origin.y, width: rect.size.width, height: rect.size.height - arrowSize.height)
let clipPath = UIBezierPath(roundedRect: rect2, cornerRadius: 5.0).cgPath
context.addPath(clipPath)
context.closePath()
context.fillPath()
// arraow vertex
context.beginPath()
let p1 = CGPoint(x: rect.origin.x + rect.size.width / 2.0 - arrowSize.width / 2.0, y: rect.origin.y + rect.size.height - arrowSize.height - 1)
context.move(to: p1)
context.addLine(to: CGPoint(x: p1.x + arrowSize.width, y: p1.y))
context.addLine(to: CGPoint(x: point.x, y: point.y))
context.addLine(to: p1)
context.fillPath()
}
if offset.y > 0 {
rect.origin.y += self.insets.top + arrowSize.height
} else {
rect.origin.y += self.insets.top
}
rect.size.height -= self.insets.top + self.insets.bottom
UIGraphicsPushContext(context)
label.draw(in: rect, withAttributes: _drawAttributes)
UIGraphicsPopContext()
context.restoreGState()
} |
adding path to context didn't work var isTop = false (UIApplication.shared.delegate as? AppDelegate)?.bindValue.value = ChartMarkerModel(isTop: isTop, value: label, rect: rect, color: color, font: font, textColor: textColor) class ChartMarkerView: UIView {
} let markerView = BalloonMarker(color: UIColor.clear,
|
I want to add small rounded corners on the marker label, is it support?
The text was updated successfully, but these errors were encountered: