- (void)configureAttributedTextSystemButton {
// Set the button's title for normal state.
NSDictionary *normalTitleAttributes = @{
NSForegroundColorAttributeName: [UIColor customBlueColor],
NSStrikethroughStyleAttributeName: @(NSUnderlineStyleSingle)
};
NSAttributedString *normalAttributedTitle = [[NSAttributedString alloc]
initWithString:NSLocalizedString(@"Button", nil)
attributes:normalTitleAttributes];
initWithString:NSLocalizedString(@"Button", nil)
attributes:normalTitleAttributes];
[self.attributedTextButton setAttributedTitle:normalAttributedTitle
forState:UIControlStateNormal];
forState:UIControlStateNormal];
// Set the button's title for highlighted state.
NSDictionary *highlightedTitleAttributes = @{
NSForegroundColorAttributeName : [UIColor customGreenColor],
NSStrikethroughStyleAttributeName: @(NSUnderlineStyleThick)
NSForegroundColorAttributeName : [UIColor customGreenColor],
NSStrikethroughStyleAttributeName: @(NSUnderlineStyleThick)
};
NSAttributedString *highlightedAttributedTitle = [[NSAttributedString
alloc] initWithString:NSLocalizedString(@"Button", nil)
attributes:highlightedTitleAttributes];
alloc] initWithString:NSLocalizedString(@"Button", nil)
attributes:highlightedTitleAttributes];
[self.attributedTextButton setAttributedTitle:highlightedAttributedTitle
forState:UIControlStateHighlighted];
[self.attributedTextButton addTarget:self
action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchUpInside];
action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchUpInside];
}
No comments:
Post a Comment