首页 > 移动平台 > 详细

iOS 按钮文字加划掉线

时间:2015-04-14 16:13:22      阅读:257      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!