Questions tagged [drawinrect]
32 questions
30
votes
2 answers
drawInRect:withAttributes vs drawInRect:withFont:lineBreakMode:alignment
I'm working on a new version of my app and am attempting to replace deprecated messages, but am not able to get past this one.
I can't figure out why drawInRect:withAttributes is not working. The code displays properly when…

Ross Pirtle
- 301
- 1
- 3
- 4
8
votes
1 answer
How to set text color when using drawInRect?
I have been using PaintCode to draw some of the graphics within my app, some of the drawn elements have text that is drawn using "drawInRect". The text is always showing up black regardless of what I do to try and set the color.
here is the code…

Nathan
- 1,609
- 4
- 25
- 42
3
votes
0 answers
NSAttributedString drawRect doesn't draw images on-screen on Mojave
I have a working app that draws NSAttributedStrings into a custom view. The NSAttributedStrings can included embedded images. This works on versions of macOS prior to Mojave. The app can display the strings on screen, print them, and save them to…

Rick Holzgrafe
- 59
- 7
3
votes
2 answers
Font problems on retina display
I'm kind of newbie in Objective-C and I need some help
My problem is that I have a subclass of UITextField, and I want to set the placeholder font to be custom with this code
- (void)drawPlaceholderInRect:(CGRect)rect {
[[self placeholder]…

Bogdan Somlea
- 604
- 3
- 15
3
votes
0 answers
drawInRect:withFont:lineBreakMode:alignment deprecation in IOS 7
I have a message of deprecated method.
The line of code is this one :
[string drawInRect:drawArea withFont:uifont lineBreakMode:linebreaks[lineBreakMode] alignment:alignments[hAlignment]];
So I want to replace it with this code…

Niknolty
- 93
- 9
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
2
votes
1 answer
iOS UIImage.drawInRect (CGContextDrawImage) performance
I have an app that lets the user manipulate items like text, images, shapes (vector images). They are stacked on top of each other like layers are in Photoshop.
To manipulate means to translate, resize, rotate.
I use drawInRect to draw all my items.…

Ilea Cristian
- 5,741
- 1
- 23
- 37
2
votes
0 answers
Xcode drawInRect split the String depending on RectSize
I would like to create a pdf dynamically. But I have problems with new pages.
Currently I am writing a text block and if that text block does not fit to the remaining Y position - I write the whole text block on a new page.
But I would like to take…

Lukas T.
- 21
- 2
2
votes
2 answers
Memory leak with UIImage method "drawInRect"
I have question about correct using UIImage and method drawInRect.
I use iPad 4,Xcode Version 6.1.1, IOS 8.1.2 and I used ARC and I have tried without ARC
So, I have image "1.jpg".
Image Properties:
Dimension: 7500 x 8871 pixels
Resolution: 72…

d2Liks
- 21
- 2
2
votes
1 answer
How do I rotate an image drawn directly to an NSView with DrawRect in an OSX app?
I'm writing an OSX app in Xcode using Objective-C. I have a window, with an NSView inside it, and that NSView is supposed to use data from an NSMutableArray containing NSNumbers to draw corresponding images on a grid such that images are drawn at…

Adam
- 125
- 4
1
vote
3 answers
Can't set font for drawInRect
I'm trying to draw text on a context, and it works.
I'm trying to set an UIfont to this text but it doesn't work. The text size remain the same.
Here my code
- (UIImage *)imageByDrawingCircleOnImage:(UIImage…

alexandre pellet
- 23
- 2
1
vote
0 answers
How to get a UIImage out of a freehand drawing UIView - iOS Swift
I have a DrawView UIView that works fine to allow you making freehand drawing over an existing UIImageView.
Here's the code I use to draw over that DrawView:
class DrawView: UIView {
/* Variables */
var lines: [Line] = []
var lastPoint:…

Frank Eno
- 2,581
- 2
- 31
- 54
1
vote
1 answer
NSString drawInRect:withAttributes: is not drawing text with greater width than the rect in iOS 7.0.3
I am trying to generate a pdf inside my app. To draw a string I'm calculating the size of the bounding rect for that string using boundingRectWithSize and then drawing the string inside a rect of that size.
The code works fine in iOS 7.1 and above…

Siddesh
- 13
- 1
- 4
1
vote
1 answer
drawInRect: withFont: iOS 7 not working
I was using a library (SGInfoAlert) which uses deprecated code drawInRect:r withFont:.
I tried changing some codes to fix it in iOS 7 but the text doesn't show. Anyone knows why this is happening?
// Changed this
//[info_ drawInRect:r…

Sonny G
- 1,331
- 1
- 12
- 22
1
vote
2 answers
drawInRect does not read / preserve UIImageView transform
I encountered a problem when I pinch, pan or rotate a UIImageview in drawInRect, the transform is not being preserved.
How can I preserve the transform in drawInRect?
I tried this but no go :(
- (UIImage*) combineImage:(UIImageView *)selectedImage…

Desmond
- 5,001
- 14
- 56
- 115