She*_*lam 3 iphone cocoa-touch objective-c nsstring quartz-graphics
我是自定义绘制一些文字:
point = CGPointMake(77, 5);
[[message valueForKey:@"user_login"] drawAtPoint:point forWidth:200
withFont:mainFont
minFontSize:MIN_MAIN_FONT_SIZE
actualFontSize:NULL
lineBreakMode:UILineBreakModeTailTruncation
baselineAdjustment:UIBaselineAdjustmentAlignBaselines];
Run Code Online (Sandbox Code Playgroud)
我该如何画5条线?相当于:
rect = CGRectMake(77, 25, 238, 68);
bodyLabel = [[UILabel alloc] initWithFrame:rect];
bodyLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:12];
bodyLabel.numberOfLines = 5;
bodyLabel.lineBreakMode = UILineBreakModeWordWrap;
bodyLabel.textColor = [UIColor blackColor];
[self.contentView addSubview: bodyLabel];
Run Code Online (Sandbox Code Playgroud)
说明-drawAtPoint:withFont:..."此方法在绘图期间不执行任何换行" 的文档.如果你使用-drawInRect:withFont:而不是-drawAtPoint:withFont:...,那么它将绘制多行.您还可以使用它-sizeWithFont:constrainedToSize:来确定尺寸.