Content-Length: 270432 | pFad | http://github.com/V8tr/AttributedStringBuilder

0D GitHub - V8tr/AttributedStringBuilder: Implementing NSAttributedString Swift function builder https://www.vadimbulavin.com/swift-function-builders-swiftui-view-builder/
Skip to content

V8tr/AttributedStringBuilder

Repository files navigation

Article related to this project


AttributedStringBuilder

A sample project showing how to implement custom Swift function builder using NSAttributedString as an example.

Usage:

class ViewController: UIViewController {
    @IBOutlet weak var label: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        label.attributedText = NSAttributedString {
            NSAttributedString {
                "Folder "
                UIImage(systemName: "folder")!
            }
            
            "\n"
            
            NSAttributedString {
                "Document "
                UIImage(systemName: "doc")!.withRenderingMode(.alwaysTemplate)
            }
            .withAttributes([
                .font: UIFont.systemFont(ofSize: 32),
                .foregroundColor: UIColor.red
            ])
        }
    }
}

Result:

Swift function builders, SwiftUI ViewBuilder

Releases

No releases published

Packages

No packages published

Languages









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/V8tr/AttributedStringBuilder

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy