32 lines
902 B
Swift
32 lines
902 B
Swift
//
|
|
// LabelAttributeStrikeThrough.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 8/3/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
public struct StrikeThroughLabelAttribute: LabelAttributeModel {
|
|
public func isEqual(_ equatable: StrikeThroughLabelAttribute) -> Bool {
|
|
return id == equatable.id
|
|
&& range == equatable.range
|
|
}
|
|
|
|
public var id = UUID()
|
|
public var location: Int
|
|
public var length: Int
|
|
|
|
public init(location: Int, length: Int) {
|
|
self.location = location
|
|
self.length = length
|
|
}
|
|
|
|
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
|
guard isValidRange(on: attributedString) else { return }
|
|
attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range)
|
|
attributedString.addAttribute(.baselineOffset, value: 0, range: range)
|
|
}
|
|
}
|