SwiftでTooltipを書く

SwiftでTooltipを書いた

こうゆうツールチップを書きました。

f:id:churabou:20190831151316p:plain

こんな感じに書けます。 本当はもう少し描画周りのリファクタしたりカスタマズ性を持たせたりしたいが、そもそも自分が使わないのでこの辺でアウトプットします。

    private let toolTip = TooltipView(option: Option(
        fillColor: UIColor(0xf59542)
        attributeText: NSAttributedString(
            string: "Top: #f59542",
            attributes: [
                .foregroundColor: UIColor.white,
                .font: UIFont.systemFont(ofSize: 14),
            ]
        ),
        padding: UIEdgeInsets(top: 2, left: 4, bottom: 2, right: 4),
        arrowPosition: .bottom(normalizedPointX: 0.4)
    ))

f:id:churabou:20190831150549p:plain

ソース

gist.github.com