//
// NSMutableAttributedString+Extension.m
//
// Created by Ryuichi Ishitsuka on 2016/01/08.
//
#import "NSMutableAttributedString+Extension.h"
@implementation NSMutableAttributedString (Extension)
-(void)insertIconImage:(UIImage*)icon bounds:(CGRect)bounds
{
NSTextAttachment *at = [[NSTextAttachment alloc] init];
at.image = icon;
at.bounds = bounds;
NSAttributedString *ns = [NSAttributedString attributedStringWithAttachment:at];
// アノテーションが残ってしまうから、文字列中から削除
NSRange range = [self.string rangeOfString:@"アノテーション"];
[self replaceCharactersInRange:range withString:@""];
// 同じところに、iconを追加
[self insertAttributedString:ns atIndex:range.location];
}
@end