富文本 + 利用UIlabel计算frame

 

NSMutableAttributedString * nn            = [self attributedWithString:@"\n"
                                                                              font:[UIFont systemFontOfSize:17.0]
                                                                             color:[UIColor clearColor]];
NSMutableAttributedString * PassportCover = [self attributedWithString:@"Title"
                                                                              font:[UIFont systemFontOfSize:15.0]
                                                                             color:[UIColor blackColor]];
NSMutableAttributedString * frontID       = [self attributedWithString:@"Title2"
                                                                              font:[UIFont systemFontOfSize:13.0]
                                                                             color:[UIColor blackColor]];
NSMutableAttributedString * JPGPicture    = [self attributedWithString:@"Title3"
                                                                              font:[UIFont systemFontOfSize:13.0]
                                                                             color:[UIColor lightGrayColor]];
[PassportCover appendAttributedString:nn];
[PassportCover appendAttributedString:frontID];
[PassportCover appendAttributedString:nn];
[PassportCover appendAttributedString:JPGPicture];
UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, KSCREEN_WIDTH - 60, 1000)];
lab.attributedText = self.titleArr[indexPath.section][indexPath.row];
lab.numberOfLines = 0;
CGSize labSize = [lab sizeThatFits:lab.bounds.size];

 

你可能感兴趣的:(随笔)