您的位置:首页 > 移动开发 > IOS开发

IOS艺术字及简单的图文混排

2015-07-19 17:57 537 查看
NSString* alertText = [NSString stringWithFormat:@" 以下%d节课程(总课酬¥%.02lf)家长们尚未结课并评价,请尽快联系家长,否则无法获取课酬。",self.courseNum,self.totalPrice];
NSMutableAttributedString* alertString = [[NSMutableAttributedString alloc]initWithString:alertText];
NSRange totalRange = NSMakeRange(0, alertString.length);
[alertString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0],NSForegroundColorAttributeName:[UIColor themePinkColor]} range:totalRange];
    //文字前边加一个图标
NSTextAttachment* textAttachment = [[NSTextAttachment alloc]initWithData:nil ofType:nil];
UIImage* alertIcon = [ UIImage imageNamed:@"lesson_icon26"];
textAttachment.image = alertIcon;
textAttachment.bounds = CGRectMake(0,-5, kAlertIconHeight, kAlertIconHeight);
[alertString insertAttributedString:[NSAttributedString attributedStringWithAttachment:textAttachment] atIndex:0];
self.alertLabel.attributedText = alertString;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: