Latest | 0.1.3 |
---|---|
Homepage | https://github.com/Keithbsmiley/KSLabel |
License | MIT |
Platforms | osx , requires ARC |
Authors |
KSLabel
A dead simple class for when you need to create a simple label
programmatically.
Methods
The only custom method available is
- (instancetype)initWithAttributedString:(NSAttributedString *)string
inView:(NSView *)view;
The attributed string should be an NSAttributedString
with whatever
attributes you want to be displayed. Be sure to set the
NSFontAttributeName
key
The passed NSView
should be the view the label will be added to. The
label will be setup to be centered within the passed view.
You can also set notificationToPost
with the name of an
NSNotification
to be posted when the label is clicked.
Example:
NSDictionary *attributes = @{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont systemFontSize]]};
NSAttributedString *string = [[NSAttributedString alloc] initWithString:@"My string"
attributes:attributes];
KSLabel *mylabel = [[KSLabel alloc] initWithAttributedString:string
inView:titleBarView];
mylabel.notificationToPost = @"Some String!";
NSNotification *notification = [NSNotification notificationWithName:@"someName"
object:someObject
userInfo:@{@"someKey": @"someObject"}]
myLabel.NSNotificationToPost = notification;
myLabel.action = @selector(doSomething:);
myLabel.cursor = [NSCursor pointingHandCursor];
[myView addSubview:mylabel];
CocoaPods
If you’re using CocoaPods, which you should be, just add this to your
Podfile.
pod 'KSLabel'
Latest podspec
{ "name": "KSLabel", "version": "0.1.3", "summary": "A drop in subclass of NSTextField for programmatically created labels.", "homepage": "https://github.com/Keithbsmiley/KSLabel", "license": "MIT", "authors": { "Keith Smiley": "[email protected]" }, "source": { "git": "https://github.com/Keithbsmiley/KSLabel.git", "tag": "0.1.3" }, "platforms": { "osx": null }, "source_files": "*.{h,m}", "requires_arc": true }
Sat, 05 Mar 2016 04:30:03 +0000