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
7
votes
2 answers

How can I add a watermark to an image using this code?

I know there are several other ways to do this; I don't want to import anything that I don't need to. If someone can help me with his code, that would be great. Currently, it is only saving the original image without the watermark image. extension…
swiftyboi
  • 2,965
  • 4
  • 25
  • 52
7
votes
3 answers

UIBlurEffect not working when trying to take screenshot programically in swift

I've blurred my view programmatically and added a share extension with screenshot but the screenshot doesn't blur my view in the image. All programming in swift Code for blurring let blurEffect = UIBlurEffect(style:.Dark) let blurView =…
Palash Sharma
  • 662
  • 1
  • 10
  • 18
7
votes
4 answers

Create multi page PDF in objective-c

I am trying to create a multipage PDF. I have followed this tutorial. This is working with a XIB file for static text and then adds a table from code. But the problem I'm having ATM is that when the table is bigger then one page. When the table has…
Steaphann
  • 2,797
  • 6
  • 50
  • 109
6
votes
2 answers

How to draw text in trapezoid (or circle)?

Let's imagine that I have some text: "Some attributed text in trapezoid." I have NSAttributedString extension, which returns me UIImage with attributed text: extension NSAttributedString { func asImage() -> UIImage? { defer { …
Vasilii Muravev
  • 3,063
  • 17
  • 45
6
votes
0 answers

Image gets blurry and zoomed out when erasing

I am using functionality of erasing image and my code is like below. You can see Video HERE. Here current_sticker_img is my Imageview NOTE: I am also using Pan Gesture for zooming image //MARK: Eraser touch event override func touchesBegan(_…
Jitendra Modi
  • 2,344
  • 12
  • 34
6
votes
2 answers

Clip UIImage to UIBezierPath (not masking)

I'm trying to clip a UIImage based on a given UIBezierPath, but the resulting image retains the original shape and size. I want the shape and size to resemble the path, i.e. the visible content of the new image. Take a look at this following…
Aleksander
  • 2,735
  • 5
  • 34
  • 57
6
votes
5 answers

Swift: Cropping a Screenshot without TabBar and NavigationBar

I have a screenshot of the entire screen, screenshot, generated using the following: let layer = UIApplication.sharedApplication().keyWindow!.layer let scale = UIScreen.mainScreen().scale UIGraphicsBeginImageContextWithOptions(layer.frame.size,…
Randoms
  • 2,110
  • 2
  • 20
  • 31
6
votes
1 answer

Image becomes blurry when painting a Image from GraphicContext?

I created a ViewController with a UIImageView in the storyboard. The ImageView is set to Aspect Fit and gets a yellow background color. Here is the photo I used for the test. When I run my app the image appears is shown below: There is no problem.…
Michael
  • 32,527
  • 49
  • 210
  • 370
5
votes
1 answer

UIGraphicsGetImageFromCurrentImageContext() returning blank image in UITableViewCell

I've been successfully using the function below to take snapshots of UIViews, however, now that I'm using it inside a UITableViewCell, it no longer works. static func pictureTaker(_ rawView: UIView) -> UIImageView { …
SuperCodeBrah
  • 2,874
  • 2
  • 19
  • 33
5
votes
1 answer

Swift: UIGraphicsBeginImageContextWithOptions scale factor set to 0 but not applied

I used to resize an image with the following code and it used to work just fine regarding the scale factor. Now with Swift 3 I can't figure out why the scale factor is not taken into account. The image is resized but the scale factor not applied. Do…
Sam
  • 1,101
  • 2
  • 13
  • 26
5
votes
2 answers

UIView drawing an arc type gauge chart

I have a chart which is in the shape of an gauge which has multiple design elements to it (see attachment). Key parts I'm struggling with is really getting a decent arc shape with dashed lines. So far I'm not sure if I should be going down Core…
sukh
  • 328
  • 2
  • 16
5
votes
1 answer

Converting a UIWebView to PDF/Image gives only one inch wide output

I'm converting a UIWebView to pdf/image with the help of the following code: NSString *heightStr = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"]; int height = [heightStr intValue]; CGFloat screenHeight…
Poles
  • 3,585
  • 9
  • 43
  • 91
4
votes
1 answer

Code to make screenshot of an entire UITableView doesn't work anymore in iOS 13

I used the code below for years to be able to capture a screenshot of an UITableView (including hidden rows) and save it to the user's phone gallery or share it. Since they updated to iOS 13 it doesn't work anymore, it captures only the visible part…
lorenzop
  • 580
  • 1
  • 6
  • 24
4
votes
1 answer

Create CIImage Pattern from image file

I'm trying to understand what is the most efficient way to create a CIImage with a pattern, based on an image file. let patternImage = UIImage(named: "pattern.png") The first approach I took: // First create UIColor pattern let uiColorPattern =…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
4
votes
3 answers

How to save UIImage after Editing with Pan, Rotate and Pinch Gesture

I'm trying to implement edit image using UIPanGesture, UIRotateGesture, and UIPinchGesture. After editing, I wish to save edited UIImage. I'm done edit image functionality. But I don't know How to save exactly perfect like native iOS Camera App. Pan…
Shawn Baek
  • 1,928
  • 3
  • 20
  • 34
1
2
3
20 21