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

Calculate point size to fit string inside a rectangle

I'm creating a thing that puts text on top of images. The biggest allowed frame for the text to be drawn is specified by our backend, and I have to do my best to fit whatever text the user enters into that rectangle. I looked up a ton of older…
Oscar Apeland
  • 6,422
  • 7
  • 44
  • 92
2
votes
1 answer

UIGraphicsBeginImageContextWithOptions analog in macOS

Here is the code that I'm using to scale images in iOS i.e. scale 500x500 image to 100x100 image and then store scaled copy: + (UIImage *)image:(UIImage *)originalImage scaledToSize:(CGSize)desiredSize { …
Alexandr Chekel
  • 382
  • 2
  • 15
2
votes
1 answer

How to render UIView/UIImageView to UIImage with exact size of the image without using the scale of screen?

I have searched a lot and have tried every single method that I could find in StackOverflow and none of them has worked. let's say I have a UIView which has a UIImageView containing a UIImage with a size of 1800x2300, this is obviously bigger than a…
Reza.Ab
  • 1,195
  • 1
  • 11
  • 21
2
votes
1 answer

Draw UIImage with float size

I want to draw UIImage for pattern background and I need need it be float size. For example: I need 7.0699929299999997 width and height. My code: UIImage *repeatedImage = [UIImage imageNamed:@"LayoutRepeatedImage"]; CGSize destinationSize =…
Artem Z.
  • 1,243
  • 2
  • 14
  • 36
2
votes
1 answer

Convert UIScrollViewPoint to UIImage + ZOOM + ROTATE

I need to crop UIImage which is loaded in UIScrollview with some rect of Another UIView which is also in UIScrollView Following is View Hierarchy --> View --> UIScrollView --> viewBase (UIView) --> UIImageView -> (Zoomed…
2
votes
1 answer

Why is there a white edge when cropping an image with UIGraphicsContext?

I am cropping an image with: UIGraphicsBeginImageContext(croppingRect.size) let context = UIGraphicsGetCurrentContext() context?.clip(to: CGRect(x: 0, y: 0, width: rect.width, height: rect.height)) image.draw(at: CGPoint(x: -rect.origin.x,…
Manuel
  • 14,274
  • 6
  • 57
  • 130
2
votes
0 answers

iOS-Charts: How to include a gap between data points & lines

I'm using iOS-Charts with Swift to draw line charts, and I'm looking for a way to place a gap between the data points (circles) and the lines themselves. Something like this: example I've tried playing around with some values under the drawLinear…
2
votes
0 answers

How to record screen without using Replaykit?

I need to record the screen to make a ten-seconds video when someone is broadcasting like the record function of "live.me" app. I can't use replaykit because I need to support iOS8. when user click the record button,I start to screen shot…
Remsay
  • 321
  • 1
  • 3
  • 4
2
votes
1 answer

Create custom segmented control using bezier path (Swift)

I'm trying to create a custom segmented control that sits underneath my search controller as seen in the mock up below Problem: I'm having difficulty with creating the pointy needle (looks like this: "^") that indicates the current index. Attempt…
2
votes
2 answers

UIImage orientation changed when drawing in UIGraphicsBeginImageContext

I want to resize the UIImage so I used below code. UIGraphicsBeginImageContext(size); [sourceImage drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage *destImage =…
Ekta Padaliya
  • 5,743
  • 3
  • 39
  • 51
2
votes
3 answers

App Crash setObjectForKey: object cannot be nil

In my application i asked user to draw sign and then i show that image in UIImageView using below Code: UIGraphicsBeginImageContext(captureView.bounds.size); [captureView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage =…
Viraj Padsala
  • 1,388
  • 1
  • 13
  • 31
2
votes
2 answers

How to scale an image down in iOS Share Extension before uploading

I am building a share extension and I need to scale large photos to a smaller size before uploading in my share extension. I'm using this code from How to resize an UIImage while maintaining its Aspect Ratio: - (UIImage*) scaleImage:(UIImage*)image…
2
votes
0 answers

drawViewHierarchyInRect is Crash on Iphone6 plus(Ios 8.2)

class func imageWithView(view : UIView) -> UIImage { println(view.bounds.size) UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0) view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true) let img =…
xuxu273
  • 21
  • 2
2
votes
1 answer

Swift: Screenshot without Tab Bar

I know it's fairly easy to take a screenshot of the entire screen, with or without the navigation and status bars, using a UIGraphicsImageContext but is there a way to take one (or crop one) so that the navigation bar is visible, but the status bar…
Randoms
  • 2,110
  • 2
  • 20
  • 31
2
votes
0 answers

Swift: Add an image over another image such that they are independent of each other

I want to do something similar to the crop feature present in the Photos app. I have a background image and over that image I am adding the crop square image using the following code. func…
JMS
  • 271
  • 4
  • 15