iOS UIButton设置下划线

作者: vision_colion | 来源:发表于2016-11-15 14:09 被阅读646次

    采用富文本的形式增加下划线

    - (void)SetUnderLine:(UIButton*)btn setTitle:(NSString*)title
    {
        NSMutableAttributedString*str = [[NSMutableAttributedStringalloc]initWithString:title];
        NSRangestrRange = {0,[strlength]};
        [straddAttribute:NSUnderlineStyleAttributeNamevalue:[NSNumbernumberWithInteger:NSUnderlineStyleSingle]range:strRange];
        [btnsetAttributedTitle:strforState:UIControlStateNormal];
    }
    

    相关文章

      网友评论

        本文标题:iOS UIButton设置下划线

        本文链接:https://www.haomeiwen.com/subject/sqzkpttx.html