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
3
votes
1 answer

Issue capturing selected views as they appear on screen with renderInContext in Swift

I have three views on my storyboard, viewA, viewB, viewC. I’m trying to screen capture only two views as they appear on screen in their current place, viewB and viewC. The trouble is, when I render them, the resulting image captured shows viewB and…
user4806509
  • 2,925
  • 5
  • 37
  • 72
3
votes
1 answer

Screenshot of current UIView distorts and stretches the UIView at UIView.DrawViewHierarchy

I'm creating a screenshot of a UIView currently displayed. I faced with an issue when controls are distorted and stretched for a moment (0.2-0.5 sec) during this process. It is reproduced for iPhone 6, 6+ ONLY. my simple code is here…
Mando
  • 11,414
  • 17
  • 86
  • 167
3
votes
0 answers

UIPasteBoard, Image & Retina Display

I'm generating an image using the following: UIGraphicsBeginImageContextWithOptions(labelView.bounds.size, NO, 2.0); [labelView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *resultingImage =…
KingPolygon
  • 4,753
  • 7
  • 43
  • 72
3
votes
1 answer

Resizing UIImage - Performance Issues

My aim is to use AVFoundation to capture and display (using an overlay view) the image captured - should be identical to the one in the preview layer. Working with the iPhone 4" screen size is fine as it simply involves a resize of the captured…
cud_programmer
  • 1,244
  • 1
  • 20
  • 37
3
votes
1 answer

draw CGImageRef (not UIImage) into image context

Here's exactly how to draw a UIImage in to context: UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f); [someUIImage drawInRect:CGRectMake(...)]; [someOtherUIImage drawInRect:CGRectMake(...)]; [someOtherUIImage…
Fattie
  • 27,874
  • 70
  • 431
  • 719
3
votes
1 answer

Why is UIGraphicsGetCurrentContext() available globally?

From Apple iOS Documentation #UIGraphicsGetCurrentContext: "In iOS 4 and later, you may call this function from any thread of your app." Also, why is the method call in C function format UIGraphicsGetCurrentContext() and not Objective-C message…
user
  • 3,388
  • 7
  • 33
  • 67
3
votes
2 answers

Clip UIImage with UIBezierPath Asynchronously

I want to add rounded corners to an UIImageView without using QuartzCore to avoid performance issues in a UIScrollView so I solved it like that: UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect…
kohaXun
  • 147
  • 1
  • 8
2
votes
1 answer

How does it know? When UIColor sets fill and UIGraphicsImageRendererContext knows how to fill

I came across an example for using UIGraphicsImageRender to draw in a tutor on Medium. The example code is as follows: let renderer = UIGraphicsImageRenderer(size: CGSize(width: 20, height: 20)) let img = renderer.image { (ctx) in let size =…
2
votes
0 answers

Unknown process name- vImageConvert_AnyToAny - failed on beginBackgroundTask

Hey So i am resizing my images on a background thread that keeps executing after the app entered the background with beginBackgroundTask along with some other code like so: func resizeImage(image: UIImage, newWidth: CGFloat) -> UIImage { let scale…
mufumade
  • 400
  • 4
  • 16
2
votes
0 answers

Swift - drawing app problem after iOS 14 update

I have built a drawing app based on the code under. When you draw a straight line these interruptions happen as shown in the picture. I assigned random colors to each new line, but it didn't change the color between the interruptions. If I test it…
Settler
  • 21
  • 1
2
votes
0 answers

IOS: When saving masked image, original image is saved?

I am masking an image using an image_mask, the following code shows that: func maskOriginalImage() -> UIImage? { if(self.maskImage != nil && self.originalImage != nil){ let maskReference = self.maskImage?.cgImage! let…
2
votes
2 answers

Swift - How to use UIGraphics blend mode?

I would like to develop a kind of progress bar animation for AppleWatch. I decided to do it all with the UIGraphicContext. Since I'm a complete beginner I don't really understand how I can apply some kind of "globalCompositeOperation" to my…
stacj
  • 1,103
  • 1
  • 7
  • 20
2
votes
0 answers

How to render a UIView to a UIImage Faster

I'm trying to render a UIView (with subviews) into a UIImage. I'm using the new iOS 10+ UIGraphicsImageRenderer as seen below let renderer = UIGraphicsImageRenderer(size: view.bounds.size) let image = renderer.image { ctx in …
siefix
  • 916
  • 1
  • 10
  • 19
2
votes
1 answer

Trying to make erase uiimage with swift

I'm trying to make eraser feature(and restore in future) for my app but facing some problems. I'm using Swift 4.2 and this what I made so far: override func touchesBegan(_ touches: Set, with event: UIEvent?) { if let touch =…
Pit WARLORD
  • 141
  • 7
2
votes
3 answers

Screenshot a view with label and transparent background in iOS and upload it to server

I want to screenshot a view and create an UIImage from it. I want the transparency attribute of the view to be maintained in my image. I tried this method after creating an extension of UIImage but the background is not transparent in the resultant…
Ankit Kumar Gupta
  • 3,994
  • 4
  • 31
  • 54