Struck through text in UILabel

In iOS 6.0 and up UILabel supports NSAttributedString
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc]initWithString:@"Your String here"];
[attributeString addAttribute:NSStrikethroughStyleAttributeName
                        range:NSMakeRange(0, [attributeString length])];
Definition :
- (void)addAttribute:(NSString *)name value:(id)value range:(NSRange)aRange
Parameters List:
name : A string specifying the attribute name. Attribute keys can be supplied by another framework or can be custom ones you define. For information about where to find the system-supplied attribute keys, see the overview section in NSAttributedString Class Reference.
value : The attribute value associated with name.
aRange : The range of characters to which the specified attribute/value pair applies.
yourLabel.attributedText = attributeString;

No comments:

Post a Comment