iOS-屬性字符串添加下划線、刪除線


常用到的屬性字符串

///定義屬性字符串
NSMutableAttributedString *att = [[NSMutableAttributedString alloc]initWithString:@""]; ///刪除線 [att addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleSingle | NSUnderlineStyleSingle) range:NSMakeRange(0, 0)]; ///字體大小 UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:17.0]; [att addAttribute:NSFontAttributeName value:font range:NSMakeRange(0,0)]; ///字體顏色 [att addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 0)]; // 下划線 [att addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, 0)];

直接賦給label就可以了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM