我有以下代码:
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
float imageHeight = self.image.size.height;
float imageWidth = self.image.size.width;
float ratio = imageHeight/imageWidth;
if(imageHeight> MAX_IMAGE_HEIGHT){
imageHeight = MAX_IMAGE_HEIGHT;
imageWidth = imageHeight/ratio;
}
if(imageWidth > MAX_IMAGE_WIDTH){
imageWidth = MAX_IMAGE_WIDTH;
imageHeight = imageWidth*ratio;
}
CGFloat yCoord = (self.bounds.size.height - imageHeight) / 2;
[self.image drawInRect:CGRectMake(10.0f, yCoord, imageWidth, imageHeight)];
yCoord = (self.bounds.size.height - MAIN_FONT_SIZE) / 2;
CGPoint point = CGPointMake(10.0 + imageWidth + 10.0, yCoord);
[self.title drawAtPoint:point
forWidth:self.bounds.size.width - (10.0 +imageWidth+20.0)
withFont:[UIFont systemFontOfSize:MAIN_FONT_SIZE]
minFontSize:MIN_MAIN_FONT_SIZE
actualFontSize:NULL
lineBreakMode:NSLineBreakByTruncatingTail
baselineAdjustment:UIBaselineAdjustmentAlignBaselines];
}
在编译这个问题时,我关于 drawAtPoint 上的弃用代码并建议我需要更改为 DrawInRect ...但我已经在这里看到了一些帖子,甚至是 SDK 文档,对于我的问题,我不知道如何管理这个...