Questions tagged [uigraphicscontext]

The UIGraphicsContext is not a class as you might think, but a set of functions that allows access to functions of CGContext. UIGraphicsContext is often used to create images or PDFs from code.

The UIGraphicsContext is the programmatic interface to the graphics contexts.

Since iOS 10 and tvOS 10 UIGraphicsRenderer and its subclasses facilitates the creation of documents via UIGraphicsRendererContext, which are based on Objective-C / Swift classes. The creation process is quite similar to working with functions from UIGraphicsContext so that these functions become less and less important.

314 questions
4
votes
0 answers

Swift UIGraphicsGetImageFromCurrentImageContext memory leaks

I have a centralized method to resize UIImages: public extension UIImage { public func scaleToSize(size: CGSize) -> UIImage { let hasAlpha = true let scale: CGFloat = 0.0 UIGraphicsBeginImageContextWithOptions(size,…
Dliix
  • 718
  • 1
  • 7
  • 20
4
votes
0 answers

Compress PDF generated using iOS UIGraphics

I have generated the PDF using the below code let pdfData = NSMutableData() UIGraphicsBeginPDFContextToData(pdfData, CGRect(x: 0, y: 0, width: 1024, height: 768), nil) guard let pdfContext = UIGraphicsGetCurrentContext() else { return } for view in…
Annie Gupta
  • 2,786
  • 15
  • 23
4
votes
1 answer

when creating pdf from UIWebview app crashing

I want to convert UIWebview (height = 4224,width = 568) into pdf to send it through mail,when I used below code app getting crashed in this line ([self.reportWebView.layer renderInContext:UIGraphicsGetCurrentContext()]). Please give me some good…
Infaz
  • 1,133
  • 9
  • 19
4
votes
0 answers

drawInRect withAttributes Crashing on iOS8 GM

UIGraphicsBeginPDFContextToFile(filePath, CGRectZero, nil); UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil); CGContextRef ctx = UIGraphicsGetCurrentContext(); UIFont *bigFont = [UIFont…
4
votes
3 answers

How to create a circular image with border (UIGraphics)?

How to create a circular image with border (UIGraphics)? P.S. I need to draw a picture. code in viewDidLoad: NSURL *url2 = [NSURL…
SpaceInvader
  • 87
  • 3
  • 8
4
votes
2 answers

Add Text on UIImage

Hi I am using this function to draw text on Image after the drawing on image is done but when I do this its showing me transparent text i.e. Text with opacity which I do not want it should be with alpha 1.0 I tried to add the fontcolor attribute…
user1169079
  • 3,053
  • 5
  • 42
  • 71
4
votes
1 answer

Null Graphics Context

Here is a code excerpt I am using: dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^ { UIGraphicsBeginImageContextWithOptions(irect.size, YES, 0.0 ); CGContextRef context = UIGraphicsGetCurrentContext(); if…
user3344003
  • 20,574
  • 3
  • 26
  • 62
4
votes
1 answer

renderInContext taxes App Memory

I'm running this code on a 2448 X 2448 pixel Image. fullScaleView is also 2448 X 2448 (fullScreenView Rect:{{0, 0}, {2448, 2448}}). The App memory jumps from 49.7MB to 240MB down to 172MB after the method is complete. It stays at 172MB. It doesn't…
Eric
  • 4,063
  • 2
  • 27
  • 49
4
votes
2 answers

iOS: Coregraphics image poor quality

I am not sure whether I can improve image quality but following code displays very poor image quality in PDF. I know its standard code to generate images from view but is there anything I could do to specify image quality or improve it? -…
Paresh Masani
  • 7,474
  • 12
  • 73
  • 139
3
votes
2 answers

Swift iOS - Overlay text onto PDF with PDFKit and UI

I'm working in Swift 5 and on iOS. I'm trying to overlay text onto a current PDF I have. I'm essentially porting code I made from an app for macOS. This is the code from the Mac version: func executeContext(at srcURL: URL, to dstURL: URL) { …
kernelpanic
  • 530
  • 2
  • 8
  • 26
3
votes
1 answer

Swift: UIGraphicsImageRendererFormat instead of UIGraphicsBeginImageContext returning blank image

I'm replacing UIGraphicsBeginImageContext with UIGraphicsImageRendererFormat to optimize performance and modernize my code. For some reason, UIGraphicsImageRendererFormat is returning a blank image in my function. I must be doing something…
Chewie The Chorkie
  • 4,896
  • 9
  • 46
  • 90
3
votes
0 answers

Printing HTML String in WKWebView Fails to Print Large PDFs

Swift 4, Xcode 9.2, iOS 11 I generate an HTML string that represents a bunch of data displayed in a WKWebView like this: //I include this so I can reference some images let bundle = Bundle.main.bundlePath //Load the…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
3
votes
0 answers

how to reduce GIF resolution with Swift 3

I have Data that contains an animated GIF and i wanted to know how to reduce it`s size before uploading it to the server. I am preferably looking for a pod that would do this but, i have looked everywhere on the internet and i couldn`t find…
PIRATE FIFI
  • 261
  • 2
  • 10
3
votes
1 answer

My ImageView's content mode stop working after I draw something on the image

Thanks for your time. The image is fine before I tap the image, and then the image is compacted after I tap it. Here is my code: I am not using storyboard, so I create everything with code, here is the ImageView. And I added the constraints with…
Bryce Chan
  • 1,639
  • 11
  • 26
3
votes
1 answer

drawHierarchy fails when afterScreenUpdates: true

I am using the following code to grab a screenshot of my view. UIGraphicsBeginImageContext(self.view.bounds.size) self.view.drawHierarchy(in: self.view.bounds, afterScreenUpdates: true) let wholeImage =…
J-Krush
  • 187
  • 3
  • 13
1 2
3
20 21