0
我有這個功能,基本上增加了一個給定的圖像低於給定的文字,我願textRect
一輪的角落,你能幫助我瞭解如何在這段代碼轉向的CGRect的邊角圓像的UIView
UIBezierPath
-(UIImage*) overlapText:(NSString*) p_text inImage:(UIImage*) p_image atPoint:(CGPoint) p_point
{
p_point.y += p_image.size.height-5;
UIFont *font = [UIFont boldSystemFontOfSize:11];
UIGraphicsBeginImageContext(CGSizeMake(p_image.size.width+15,p_image.size.height+15));
CGFloat imageX = (p_image.size.width+10)/2 - (p_image.size.width/2);
[p_image drawInRect:CGRectMake(imageX,0,p_image.size.width,p_image.size.height)];
CGRect textRect = CGRectMake(0, p_point.y, p_image.size.width+15, p_image.size.height+10);
[[UIColor colorWithRed:(70/255.0) green:(70/255.0) blue:(70/255.0) alpha:1] set];
CGContextFillRect(UIGraphicsGetCurrentContext(), textRect);
[[UIColor whiteColor] set];
[p_text drawInRect:textRect withFont:font lineBreakMode:NSLineBreakByTruncatingTail alignment:NSTextAlignmentCenter];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
你能幫我一下代碼嗎?我刪除CGRect? –
CGRect只是一個路徑。我在說,使用不同的路徑。你在說'CGContextFillRect'。這繪製了一個填充的矩形。我建議你畫一個填充的圓角矩形。 – matt