Created
March 9, 2021 14:44
-
-
Save trilliwon/daf5f5d4447e91d77bb1161e318b4fa9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
@_functionBuilder | |
public class NSAttributedStringBuilder { | |
public static func buildBlock(_ components: NSAttributedString...) -> NSAttributedString { | |
let att = NSMutableAttributedString(string: "") | |
return components.reduce(into: att) { $0.append($1) } | |
} | |
} | |
public extension NSAttributedString { | |
class func composing(@NSAttributedStringBuilder _ parts: () -> NSAttributedString) -> NSAttributedString { | |
parts() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment