給button和label添加下劃線有這麼幾種方式
1.用NSAttributedString
2.自定義button和label在其drawRect方法中繪製下劃線
3.用第三方的開源庫,用過的有
RTLabel https://github.com/vichuda/RTLabel
TTTAttributedLabel https://github.com/mattt/TTTAttributedLabel/
(這兩個其實也是用NSAttributedString來實現的,只不過封裝的比較好用一點,有一些對CoreText的api調用)
老外的一個帖子列的比較全,我就直接貼在這
http://stackoverflow.com/questions/2630004/underlining-text-in-uibutton
總結:以後有時間要研究一下CoreText庫,富文本會用到,暫且列在這,以後慢慢整理學習筆記