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
                        value:@2
                        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.
Then
yourLabel.attributedText = attributeString;

Comments

Popular posts from this blog

Scroll UITextField above Keyboard in a UITableView OR UIScrollView in Swift and Objective C

Reverting all Xcode settings to default settings

CGRectIntegral