码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 按钮文字加划掉线

时间:2015-04-14 16:13:36      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

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];

 

iOS 按钮文字加划掉线

标签:

原文地址:http://www.cnblogs.com/lihaibo-Leao/p/4424998.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!