Questions tagged [uigraphicsimagerenderer]
34 questions
1
vote
1 answer
Resize Image in stackView, keep aspect-ratio
I want to clone the Apple Maps App UIButtons, they look like this:
This is my Code:
class CustomView: UIImageView {
init(frame: CGRect, corners: CACornerMask, systemName: String) {
super.init(frame: frame)
…

user12473575
- 73
- 7
1
vote
3 answers
Using CGContext of UIGraphicImageRenderer to redraw an image, flipped the image. How to prevent the flip?
Given an image, when I want to convert to standard sRGB, I can CGContext to help draw it as below.
Given the original image
When I use the CGContext directly, it redraws correctly
extension UIImage {
func toSRGB() -> UIImage {
…

Elye
- 53,639
- 54
- 212
- 474
1
vote
2 answers
How to make an ellipse/circular UIImage with transparent background?
This is the code I am using
extension UIImage {
var ellipseMasked: UIImage? {
guard let cgImage = cgImage else { return nil }
let rect = CGRect(origin: .zero, size: size)
return UIGraphicsImageRenderer(size:…

echo
- 1,244
- 1
- 16
- 40
0
votes
0 answers
UIGraphicsImageRenderer does not see some content on PDFPage
I use code from huckingwithswift.com as it is:
private func imageFromPDF(page: CGPDFPage) -> UIImage {
let pageRect = page.getBoxRect(.mediaBox)
let renderer = UIGraphicsImageRenderer(size: pageRect.size)
let image = renderer.image { ctx…

Konstantin.Efimenko
- 1,242
- 1
- 14
- 38
0
votes
0 answers
Why image from UIGraphicsImageRenderer used with PDFPage is faded?
This is how I create PDFDocument:
let document = PDFDocument()
for image in images {
let page = PDFPage(image: image.scaledWithMaxWidthOrHeightValue(value: 425)!)!
document.insert(page, at: document.pageCount)
}
And here is an extension…

Bartłomiej Semańczyk
- 59,234
- 49
- 233
- 358
0
votes
0 answers
UIGraphicsImageRenderer: iosurface is too large for GPU
I use UIGraphicsImageRenderer to draw a large image, but the Xcode logging Metal API Validation Enabled and [Metal] 5073 by 8663 iosurface is too large for GPU. The resulting image is a blank image with a very small size.
let format =…

K.B.
- 291
- 2
- 13
0
votes
1 answer
Can't get CALayer or UIView from SwiftSVG to render to UIImage with UIGraphicsImageRenderer()
I'm trying to render a CALayer from SwiftSVG package (on github) as a UIImage. It isn't working.
Source .svg file defines a viewBox 1169 x 1000.
If I add CALayer to UIView and add UIView (not UIImage) to view hierarchy, the SVG graphics are perfect,…

clearlight
- 12,255
- 11
- 57
- 75
0
votes
1 answer
overwrite set system properties at runtime in maven pom
I am using org.eclipse.images.renderer plugin to render my images from svg to png. Eclipse has provided support to create highDpi icons as well which requires 2 more arguments to be passed
eclipse.svg.scale=2 and eclipse.svg.createFragments=false…

Ravi Bodla
- 1
- 1
0
votes
1 answer
[__NSCFType set]: unrecognized selector with NSAttributedString:draw() gets called, based on width of position
If the code below is run it causes an exception
'NSInvalidArgumentException', reason: '-[__NSCFType set]: unrecognized
selector sent to instance 0x283130be0'
However, the exception can be removed by reducing the width value from 100.0 in…

Gruntcakes
- 37,738
- 44
- 184
- 378
0
votes
1 answer
Unable to generate cgImage from UIGraphics
I am developing a game which needs to render tiled pipe form the previously loaded cgImage. For this purpose I am using the following code, however the resized image is not rendered Can someone give me an advice how to fix that?
EDIT: to include…

Dakata
- 1,227
- 2
- 14
- 33
0
votes
2 answers
Why draw(in: CGRect) draws border around ellipse when it should not?
This is my simple function I use for drawing an image in context:
let renderer=UIGraphicsImageRenderer(size: CGSize(width: 330, height: 330))
let img=renderer.image{ ctx in
let circle=CGRect(x:0,y:0,width: 330, height: 330)
…

Bartłomiej Semańczyk
- 59,234
- 49
- 233
- 358
0
votes
0 answers
Cannot Convert SwiftUI view to UIImage
I have tried more than a few ways to convert a view to an image in swift. The one that seems the simplest is Hacking With Swift's implementation. The problem is, it returns a blank image and a not in the console saying "[Snapshotting] View (view)…

Mark Reggiardo
- 467
- 2
- 4
- 15
0
votes
1 answer
How to increase quality of rendered image for UIImageView?
I have an UIImageView with contentMode = .aspectFit. I have an image in imageView, which dimension is bigger than size of imageView. User can draw some lines and save them as sublayer. After that I need to save the edited image. But quality of saved…

Сергій Насінник
- 33
- 5
0
votes
1 answer
Weird error when trying to take a snapshot of a uiview using UIGraphicsImageRenderer
I'm getting the following error when I call this extension:
extension UIView {
/// Create image snapshot of view.
func snapshot(of rect: CGRect? = nil) -> UIImage {
return UIGraphicsImageRenderer(bounds: rect ?? bounds).image {…

Mavro
- 571
- 8
- 19
0
votes
1 answer
How can i wait for 2 seperate UIGraphicsImageRenderer tasks to complete
I have 2 UIGraphicsImageRenderer tasks with different renderers and when i run this, only one task is returned as it is synchronous, how do I wait until both have created images before returning them?
func createShareImage(callback: @escaping (_…

Halpo
- 2,982
- 3
- 25
- 54