在我的代码中:
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"12123"];
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
attachment.image = [UIImage imageNamed:@"002"];
attachment.bounds = CGRectMake(0, 0, 20, 20);
[str insertAttributedString:[NSAttributedString attributedStringWithAttachment:attachment] atIndex:2];
CGRect rect = [str boundingRectWithSize:CGSizeMake(200, CGFLOAT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
context:nil];
Run Code Online (Sandbox Code Playgroud)
结构'rect'不正确,为什么?