mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
3ed0abbc30
Добавил возможность задавать фоны в ренджах.
24 lines
541 B
Swift
24 lines
541 B
Swift
// Copyright 2021 Yandex LLC. All rights reserved.
|
|
|
|
import CoreGraphics
|
|
import Foundation
|
|
|
|
public final class BackgroundAttribute {
|
|
public static let Key = NSAttributedString.Key("RangeBackground")
|
|
|
|
public let color: CGColor
|
|
public let range: CFRange
|
|
|
|
public init(
|
|
color: CGColor,
|
|
range: CFRange
|
|
) {
|
|
self.color = color
|
|
self.range = range
|
|
}
|
|
|
|
public func apply(to str: CFMutableAttributedString, at range: CFRange) {
|
|
CFAttributedStringSetAttribute(str, range, BackgroundAttribute.Key as CFString, self)
|
|
}
|
|
}
|