-2
我想用Uilabeltextfield保存圖像。 我可以保存它們,但所有的文本框都是黑色的。 我嘗試從屬性檢查器更改,但沒有任何更改。 任何人都可以幫助我將Uilabel文本字段保存爲白色。 也我需要粗體字體。用文本顏色保存Uilabel
謝謝。
UIGraphicsBeginImageContextWithOptions(self.mainImage.bounds.size, YES, 0.0);
[self.mainImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.goalkeeperImage.image drawInRect:CGRectMake(self.goalkeeperImage.frame.origin.x, self.goalkeeperImage.frame.origin.y, self.goalkeeperImage.frame.size.width, self.goalkeeperImage.frame.size.height)];
[self.goalkeeperText.text drawInRect:CGRectMake(self.goalkeeperText.frame.origin.x, self.goalkeeperText.frame.origin.y, self.goalkeeperText.frame.size.width,self.goalkeeperText.frame.size.height) withAttributes:nil ];
[self.datelabeltext.text drawInRect:CGRectMake(self.datelabeltext.frame.origin.x, self.datelabeltext.frame.origin.y, self.datelabeltext.frame.size.width,self.datelabeltext.frame.size.height) withAttributes: nil ];
UIImage *SaveImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(SaveImage, self,@selector(image:didFinishSavingWithError:contextInfo:), nil);
使用'JavasText'而不是'text'。然後,您可以使用任何您需要的字體屬性和顏色來設置屬性文本。 – rmaddy
我改變了; [self.datelabeltext.attributedText drawWithRect:CGRectMake(self.datelabeltext.frame.origin.x,self.datelabeltext.frame.origin.y,self.datelabeltext.frame.size.width,self.datelabeltext.frame.size.height)選項:@selector(fontAttributes)context:nil];它的工作原理,但Xcode給我一個警告「'不兼容指針整數轉換髮送'SEL'類型參數'NSStringDrawingOptions'(又名'枚舉NSStringDrawingOptions') – user3106377