27 lines
692 B
Swift
27 lines
692 B
Swift
//
|
|
// LabelAttributeAttachment.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 8/9/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
public protocol LabelAttributeAttachment: LabelAttributeModel {
|
|
func getAttachment() throws -> NSTextAttachment
|
|
}
|
|
|
|
extension LabelAttributeAttachment {
|
|
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
|
do {
|
|
let mutableString = NSMutableAttributedString()
|
|
let attachment = try getAttachment()
|
|
mutableString.append(NSAttributedString(attachment: attachment))
|
|
attributedString.insert(mutableString, at: location)
|
|
} catch {
|
|
//TODO: Error Handling
|
|
}
|
|
}
|
|
}
|