我想在CGRect的底部畫一個NSString。到目前爲止,我已經能夠將文本置於頂部居中,但我需要將其置於底部。我也試過DrawAtPoint,但沒有奏效。這是我目前擁有的代碼: UIGraphicsBeginImageContext(img.size);在CGRect中繪製NSString
CGRect aRectangle = CGRectMake(0,0, img.size.width, img.size.height);
[img drawInRect:aRectangle];
[[UIColor whiteColor] set];
NSInteger fontSize = 25;
UIFont *font = [UIFont boldSystemFontOfSize: fontSize];
[text drawInRect:aRectangle withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter];
UIImage *theImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
我試圖用drawAtPoint視圖倍,但由於某種原因,它不加入在矩形的頂部繪製。 –
你也可以drawInRect,但矩形尺寸計算sizeWithFont:constrainedToSize:lineBreakMode – blackmilk
這是我的整個代碼,所以你可以更好地瞭解我在做什麼。 –