iOS 按钮文字加划掉线

UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(20, 50, 120, 40)];
    
    NSDictionary *normalTitleAttributes = @{
                                            NSForegroundColorAttributeName: [UIColor blueColor],
                                            NSStrikethroughStyleAttributeName: @(NSUnderlineStyleSingle)
                                            };
    NSAttributedString *normalAttributedTitle = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Button", nil) attributes:normalTitleAttributes];
    [btn setAttributedTitle:normalAttributedTitle forState:UIControlStateNormal];
    
    // Set the button's title for highlighted state.
    NSDictionary *highlightedTitleAttributes = @{
                                                 NSForegroundColorAttributeName : [UIColor blueColor],
                                                 NSStrikethroughStyleAttributeName: @(NSUnderlineStyleThick)
                                                 };
    NSAttributedString *highlightedAttributedTitle = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Button", nil) attributes:highlightedTitleAttributes];
    [btn setAttributedTitle:highlightedAttributedTitle forState:UIControlStateHighlighted];
    
    [btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btn];
原文地址:https://www.cnblogs.com/lihaibo-Leao/p/4424998.html