private UIImage TextToImage(string drawText, UIImage image,CGRect fream)
{
UIGraphics.BeginImageContext(new CGSize(image.Size.Width, image.Size.Height));
var imageCgrect = new CGRect(0, 0, image.Size.Width, image.Size.Height);
image.DrawAsPatternInRect(imageCgrect);
var rect = new CGRect(fream.X, fream.Y, image.Size.Width, image.Size.Height);
var attributedString = new NSAttributedString(drawText,
new CTStringAttributes
{
ForegroundColorFromContext = true,
Font = new CTFont("Arial", 25),
});
attributedString.DrawString(rect);
var newImage = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return newImage;
}
{
UIGraphics.BeginImageContext(new CGSize(image.Size.Width, image.Size.Height));
var imageCgrect = new CGRect(0, 0, image.Size.Width, image.Size.Height);
image.DrawAsPatternInRect(imageCgrect);
var rect = new CGRect(fream.X, fream.Y, image.Size.Width, image.Size.Height);
var attributedString = new NSAttributedString(drawText,
new CTStringAttributes
{
ForegroundColorFromContext = true,
Font = new CTFont("Arial", 25),
});
attributedString.DrawString(rect);
var newImage = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return newImage;
}