NSMutableAttributedString常用代码

        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];

        attachment.image = [UIImage imageNamed:@"mine_chat_popview_jinyan_icon"];

        attachment.bounds = CGRectMake(0, -5, 21, 21);

 

        NSMutableAttributedString *attributed = [[NSMutableAttributedString alloc] initWithAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];

        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"禁言"];

        [str addAttribute:NSForegroundColorAttributeName value:MAKECOLOR(28, 210, 133) range:NSMakeRange(0,2)];

        [attributed appendAttributedString:str];

        [self.jinyanBtn setAttributedTitle:attributed forState:UIControlStateNormal];

posted on 2016-09-29 11:21  活最好的自己  阅读(176)  评论(0编辑  收藏  举报

导航