You can do this like this, assuming _textField set as the output in your xib:
- (void) awakeFromNib { NSMutableAttributedString *as = [[_textField attributedStringValue] mutableCopy]; [as addAttribute:NSStrikethroughStyleAttributeName value:(NSNumber *)kCFBooleanTrue range:NSMakeRange(0, [as length])]; [_textField setAttributedStringValue:[as autorelease]]; }
Edit:
If you want to write your own NSTextFieldCell subheading instead, the only way you will need to override is setStringValue:
- (void) setStringValue:(NSString *)aString { NSMutableAttributedString *as = [[NSMutableAttributedString alloc] initWithString:aString]; [as addAttribute:NSStrikethroughStyleAttributeName value:(NSNumber *)kCFBooleanTrue range:NSMakeRange(0, [as length])]; [self setAttributedStringValue:[as autorelease]]; }
source share