EvaluateTableViewCell.h #import <UIKit/UIKit.h>
@interface Evaluatetableviewcell:uitableviewcell @property (Nonatomic,strong) Uilabel *phonelabel; @property (Nonatomic,strong) Uilabel *timelabel; @property (Nonatomic,strong) Uilabel *desclabel; @property (Nonatomic,strong) UIView *intervalview;
Evaluate content and implement automatic line wrapping -(void) Setintroductiontext: (nsstring*) text;
@end evaluatetableviewcell.m -(Instancetype) Initwithstyle: (Uitableviewcellstyle) style Reuseidentifier: (NSString *) reuseidentifier { self = [super Initwithstyle:style reuseidentifier:reuseidentifier]; if (self) { User cell phone number Self.phonelabel = [[Uilabel alloc] Initwithframe:cgrectmake (7, 15, 100, 12)]; Self.phoneLabel.font = Font (12); [Self AddSubview:self.phoneLabel]; Evaluation time Self.timelabel = [[Uilabel alloc] Initwithframe:cgrectmake (247 * (kscreenwidth/320), 15, 72, 11)]; Self.timeLabel.font = Font (11); Self.timeLabel.textColor = [Uicolor Graycolor]; [Self AddSubview:self.timeLabel]; Separator line UIView *lineview = [[UIView alloc] Initwithframe:cgrectmake (8, Self.timeLabel.maxY +-, kScreenWidth-16, 1)]; Lineview.backgroundcolor = [Uicolor blackcolor]; [Self addsubview:lineview]; Evaluation Content Self.desclabel = [[Uilabel alloc] Initwithframe:cgrectmake (one, lineview.maxy+, KScreenWidth-22, 13)]; Self.descLabel.font = Font (12); Self.descLabel.numberOfLines = 0; [Self AddSubview:self.descLabel]; Interval Self.intervalview = [[UIView alloc] Initwithframe:cgrectmake (0, Self.descLabel.maxY + 9, Kscreenwidth, 2)]; Self.intervalView.backgroundColor = [Uicolor blackcolor]; [Self addSubview:self.intervalView]; } return self; } Assignment and automatic line wrapping to calculate the cell height -(void) Setintroductiontext: (nsstring*) text{ Get current Cell height CGRect frame = [self frame]; Text Assignment Self.descLabel.text = text; Set the maximum number of rows for a label Cgsize size = Cgsizemake (300, 1000); Cgsize labelsize = [Self.descLabel.text sizeWithFont:self.descLabel.font constrainedtosize:size Linebreakmode: Nslinebreakbyclipping]; Self.descLabel.frame = CGRectMake (self.desclabel.frame.origin.x, SELF.DESCLABEL.FRAME.ORIGIN.Y, Labelsize.width, Labelsize.height);
Calculate the height of the adaptation Frame.size.height = labelsize.height + 85; Self.frame = frame; Self.intervalView.frame = CGRectMake (0, Self.descLabel.maxY + 9, kscreenwidth, 4); }
|