NSAttributedString富文本

typedef NS_ENUM(NSInteger, FRNoteStepsType) {//B加粗? I傾斜? U下劃線? S中間橫線

? ? FRNoteStepsTypeTextNormal=3030,//Note頁輸入字體無狀態(tài)

? ? FRNoteStepsTypeTextBold,//Note頁輸入字體加粗

? ? FRNoteStepsTypeTextTilt,//Note頁輸入字體傾斜

? ? FRNoteStepsTypeTextTiltUnderLine,//Note頁輸入字體添加下劃線

? ? FRNoteStepsTypeTextTiltHorizontalLine,//Note頁輸入字體添加中間橫線

? ? FRNoteStepsTypeTextBI,//加粗+傾斜

? ? FRNoteStepsTypeTextBU,//加粗+下劃線

? ? FRNoteStepsTypeTextBS,//加粗+中間橫線

? ? FRNoteStepsTypeTextIU,//傾斜+下劃線

? ? FRNoteStepsTypeTextIS,//傾斜+中間橫線

? ? FRNoteStepsTypeTextUS,//下劃線+中間橫線

? ? FRNoteStepsTypeTextBIU,//加粗+傾斜+下劃線

? ? FRNoteStepsTypeTextBIS,//加粗+傾斜+中間橫線

? ? FRNoteStepsTypeTextBUS,//加粗+下劃線+中間橫線

? ? FRNoteStepsTypeTextIUS,//傾斜+下劃線+中間橫線

? ? FRNoteStepsTypeTextBIUS,//加粗+傾斜+下劃線+中間橫線

};



//設(shè)置新的富文本內(nèi)容

+ (NSAttributedString*)getNewsAttribute:(NSString*)inputTexttextAttribute:(FRNoteStepsType)textAttribute textColor:(UIColor*)textColor{


? ? UIColor*attColor = textColor ? textColor :kBaseModel.cellTitleColor;


? ? switch(textAttribute) {

? ? ? ? case FRNoteStepsTypeTextNormal://Note頁輸入字體無狀態(tài)

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_SystemFont(16),NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextBold://Note頁輸入字體加粗

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_MediumFont(16),NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextTilt://Note頁輸入字體傾斜

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName :FR_SystemFont(16),NSObliquenessAttributeName : @(0.5),NSExpansionAttributeName : @(0),NSVerticalGlyphFormAttributeName : @(0),NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextTiltUnderLine://Note頁輸入字體添加下劃線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName :FR_SystemFont(16),NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle),NSUnderlineColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextTiltHorizontalLine://Note頁輸入字體添加中間橫線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName :FR_SystemFont(16),NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle),NSStrikethroughColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;


? ? ? ? case FRNoteStepsTypeTextBI://加粗+傾斜

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_MediumFont(16),NSObliquenessAttributeName : @(0.5),NSExpansionAttributeName : @(0),NSVerticalGlyphFormAttributeName : @(0),NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextBU://加粗+下劃線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_MediumFont(16),NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle),NSUnderlineColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextBS://加粗+中間橫線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_MediumFont(16),NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle),NSStrikethroughColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextBIU://加粗+傾斜+下劃線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_MediumFont(16),NSObliquenessAttributeName : @(0.5),NSExpansionAttributeName : @(0),NSVerticalGlyphFormAttributeName : @(0),NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle),NSUnderlineColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextBIS://加粗+傾斜+中間橫線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_MediumFont(16),NSObliquenessAttributeName : @(0.5),NSExpansionAttributeName : @(0),NSVerticalGlyphFormAttributeName : @(0),NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle),NSStrikethroughColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextBUS://加粗+下劃線+中間橫線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_MediumFont(16),NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle),NSUnderlineColorAttributeName : attColor,NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle),NSStrikethroughColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextBIUS://加粗+傾斜+下劃線+中間橫線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_MediumFont(16),NSObliquenessAttributeName : @(0.5),NSExpansionAttributeName : @(0),NSVerticalGlyphFormAttributeName : @(0),NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle),NSUnderlineColorAttributeName : attColor,NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle),NSStrikethroughColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextIU://傾斜+下劃線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName :FR_SystemFont(16),NSObliquenessAttributeName : @(0.5),NSExpansionAttributeName : @(0),NSVerticalGlyphFormAttributeName : @(0),NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle),NSUnderlineColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextIS://傾斜+中間橫線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_SystemFont(16),NSObliquenessAttributeName : @(0.5),NSExpansionAttributeName : @(0),NSVerticalGlyphFormAttributeName : @(0),NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle),NSStrikethroughColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextIUS://傾斜+下劃線+中間橫線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName : FR_SystemFont(16),NSObliquenessAttributeName : @(0.5),NSExpansionAttributeName : @(0),NSVerticalGlyphFormAttributeName : @(0),NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle),NSUnderlineColorAttributeName : attColor,NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle),NSStrikethroughColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;

? ? ? ? case FRNoteStepsTypeTextUS://下劃線+中間橫線

? ? ? ? {

? ? ? ? ? ? NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:inputText attributes:@{NSForegroundColorAttributeName:attColor,NSFontAttributeName :FR_SystemFont(16),NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle),NSUnderlineColorAttributeName : attColor,NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle),NSStrikethroughColorAttributeName : attColor,NSKernAttributeName :@(1)}];

? ? ? ? ? ? returnattributeStr;

? ? ? ? }

? ? ? ? ? ? break;


? ? ? ? default:

? ? ? ? ? ? break;

? ? }

?? ?return [[NSAttributedString alloc]initWithString:inputText];

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末爵政,一起剝皮案震驚了整個濱河市仅讽,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌钾挟,老刑警劉巖洁灵,帶你破解...
    沈念sama閱讀 219,427評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異等龙,居然都是意外死亡处渣,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,551評論 3 395
  • 文/潘曉璐 我一進店門蛛砰,熙熙樓的掌柜王于貴愁眉苦臉地迎上來罐栈,“玉大人,你說我怎么就攤上這事泥畅≤埽” “怎么了?”我有些...
    開封第一講書人閱讀 165,747評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我业岁,道長狼荞,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,939評論 1 295
  • 正文 為了忘掉前任谎亩,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘有决。我一直安慰自己,他們只是感情好空盼,可當(dāng)我...
    茶點故事閱讀 67,955評論 6 392
  • 文/花漫 我一把揭開白布书幕。 她就那樣靜靜地躺著,像睡著了一般揽趾。 火紅的嫁衣襯著肌膚如雪台汇。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,737評論 1 305
  • 那天篱瞎,我揣著相機與錄音苟呐,去河邊找鬼。 笑死俐筋,一個胖子當(dāng)著我的面吹牛掠抬,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播校哎,決...
    沈念sama閱讀 40,448評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼两波,長吁一口氣:“原來是場噩夢啊……” “哼瞳步!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起腰奋,我...
    開封第一講書人閱讀 39,352評論 0 276
  • 序言:老撾萬榮一對情侶失蹤单起,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后劣坊,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體嘀倒,經(jīng)...
    沈念sama閱讀 45,834評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,992評論 3 338
  • 正文 我和宋清朗相戀三年局冰,在試婚紗的時候發(fā)現(xiàn)自己被綠了测蘑。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,133評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡康二,死狀恐怖碳胳,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情沫勿,我是刑警寧澤挨约,帶...
    沈念sama閱讀 35,815評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站产雹,受9級特大地震影響诫惭,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜蔓挖,卻給世界環(huán)境...
    茶點故事閱讀 41,477評論 3 331
  • 文/蒙蒙 一夕土、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧瘟判,春花似錦怨绣、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,022評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽开镣。三九已至刀诬,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間邪财,已是汗流浹背陕壹。 一陣腳步聲響...
    開封第一講書人閱讀 33,147評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留树埠,地道東北人糠馆。 一個月前我還...
    沈念sama閱讀 48,398評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像怎憋,于是被迫代替她去往敵國和親又碌。 傳聞我的和親對象是個殘疾皇子九昧,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,077評論 2 355

推薦閱讀更多精彩內(nèi)容