VPAttributedFormat
NSAttributedString+VPAttributedFormat
Install / Use
/learn @Visput/VPAttributedFormatREADME
VPAttributedFormat v1.2.5
VPAttributedFormat project represents categories:
- NSAttributedString+VPAttributedFormat
- UILabel+VPAttributedFormat
- UITextView+VPAttributedFormat
- UITextField+VPAttributedFormat
- UIButton+VPAttributedFormat
These categories provide methods for building attributed string based on attributed format and arguments that should satisfy this format.
The most suitable case of using these categories is text controls with variable attributed text configured in interface builder.
You need set correct string format to attributed text and configure necessary attributes.
Then you need pass necessary arguments in code by using methods of these categories.
All standard controls that work with attributed strings are supported: UILabel, UITextView, UITextField, UIButton.
See Usage and Examples sections for more details.
Full documentation is available on CocoaDocs.

Installation
Cocoa Pods
Add to your Podfile:
pod "VPAttributedFormat"
Drag&Drop
- Drag and drop VPAttributedFormat.xcodeproj to your project;
- Add VPAttributedFormat to Build Settings -> Target Dependencies;
- Add VPAttributedFormat.framework to Build Settings -> Link Binary With Libraries;
- Add "-all_load" flag to Build Settings -> Other Linker Flags.
Usage<a name="usage"></a>
Import framework header or module
// Objective C
// By header
#import <VPAttributedFormat/VPAttributedFormat.h>
// By module
@import VPAttributedFormat;
// Swift
import VPAttributedFormat
Set correct format and attributes for text control in interface builder

Create IBOutlet and link it with text control
// Objective C
@property (nonatomic, weak) IBOutlet UILabel *textLabel;
// Swift
@IBOutlet weak var textLabel: UILabel!
Populate format with necessary arguments
Set arguments multiple times
Use UILabel / UITextView / UITextField / UIButton category methods.
Set keepFormat parameter to YES.
// Objective C
NSString *hot = @"Hot";
NSString *cold = @"Cold";
[self.textLabel vp_setAttributedTextFormatArguments:YES, hot, cold];
// Swift
let hot = "Hot"
let cold = "Cold"
var arguments: [CVarArgType] = [hot, cold]
withVaList(arguments) { pointer in
textLabel.vp_setAttributedTextFormatArguments(pointer, keepFormat: true);
}
Set arguments only once
Use UILabel / UITextView / UITextField / UIButton category methods.
Set keepFormat parameter to NO.
// Objective C
NSString *hot = @"Hot";
NSString *cold = @"Cold";
[self.textLabel vp_setAttributedTextFormatArguments:NO, hot, cold];
// Swift
let hot = "Hot"
let cold = "Cold"
var arguments: [CVarArgType] = [hot, cold]
withVaList(arguments) { pointer in
textLabel.vp_setAttributedTextFormatArguments(pointer, keepFormat: false);
}
Set attributed text directly
Use NSAttributedString category methods.
It's suitable for situations when attributed format comes from another part of application.
// Objective C
NSString *hot = @"Hot";
NSString *cold = @"Cold";
self.textLabel.attributedText = [NSAttributedString vp_attributedStringWithAttributedFormat:self.textLabel.attributedText,
hot,
cold];
// Swift
let hot = "Hot"
let cold = "Cold"
var arguments: [CVarArgType] = [hot, cold]
textLabel.attributedText = withVaList(arguments) { pointer in
NSAttributedString.vp_attributedStringWithAttributedFormat(textLabel.attributedText, arguments: pointer)
}
Enjoy!

System Requirements
It requires building with iOS SDK 6.0 and later.
It can be used in Objective C and Swift code.
Examples<a name="examples"></a>
VPAttributedFormatExample is an example project. It provides Basic and Pro format examples.
License
VPAttributedFormat is released under the MIT license. See LICENSE for details.
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
