Questions tagged [drawrect]

Method in UIView/NSView class. Draws the receiver’s image within the passed-in rectangle.

Signature

- (void)drawRect:(CGRect)rect

rect - The portion of the view’s bounds that needs to be updated. The first time your view is drawn, this rectangle is typically the entire visible bounds of your view. However, during subsequent drawing operations, the rectangle may specify only part of your view.

The default implementation of this method does nothing. Subclasses that use native drawing technologies (such as Core Graphics and UIKit) to draw their view’s content should override this method and implement their drawing code there.

1051 questions
0
votes
3 answers

iOS unable to draw simple line

- (void)drawRect:(CGRect)rect { CGFloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f}; CGContextSetStrokeColor(c, red); CGContextBeginPath(c); CGContextMoveToPoint(c, 150.0f, 200.0f); CGContextSetLineWidth(c, 5.0f); CGContextAddLineToPoint(c,…
Alan Lai
  • 1,296
  • 2
  • 12
  • 16
0
votes
2 answers

drawRect inverts imageView in iPhone (Simulator)

I have seen this and this but it doesn't clear my doubt. I have a custom imageView class, a subclass basically. where I need to add sub image views on a UIView at particular pixel values. When I draw these images using custom imageview (draw rect)…
Vjlakshmi
  • 80
  • 8
0
votes
1 answer

IOS - save or cache DrawRect image

I have a UIView with lots of image is drawn from drawRect when drawn finished, i wanna save(cache) all of image How to save(cache) all of image in drawRect or something like that! Thank everyone for looking this article.
heaven
  • 221
  • 4
  • 19
0
votes
0 answers

setNeedsDisplay not causing refresh drawRect

my project is some kind of a timing application for Mac OS X and I want to cause drawRect in TimeCircle to refresh myView. I´m aware that I asked a similar question before. But my problem is not solved yet and it is different from other topics which…
Ronald Hofmann
  • 1,390
  • 2
  • 15
  • 26
0
votes
1 answer

OSX Cocoa: Error in resetting colors in two drawRect method implementations

I have a Table subclass of NSView which contains several blocks of the Block subclass of NSView. This is the code for Table's drawRect: method: - (void)drawRect:(NSRect)dirtyRect { [NSGraphicsContext saveGraphicsState]; [[[NSColor…
BigCola
  • 312
  • 1
  • 4
  • 16
0
votes
1 answer

Advice for image overlay

I'm looking for some advice on how to proceed. I'm working on a cocoa program (Objective-C) where I want to be able to draw over top of a bitmap image, defining areas that I can use to get information from the underlying image. As an example, I'd…
P-Rod
  • 471
  • 1
  • 5
  • 18
0
votes
1 answer

Constant animation in IOS

I have a graph which is 10 times the width of the iphone screen. I want to scroll it automatically a fixed number of points (for instance 0.01) every 0.2 seconds. I want the animation to stop when a user presses a pause button and to pick up from…
mgamer
  • 13,580
  • 25
  • 87
  • 145
0
votes
1 answer

How do i get rid of a line drawn by drawRect to disappear .05 seconds after the user touches the screen?

I have the touchesBegan void before this which triggers this event, but i need this line to show, wait for so many seconds, then disappear: - (void)drawRect:(CGRect)rect { // Drawing code //Make a simple rectangle and fill background BLUE…
0
votes
1 answer

IOS - DrawRect Image

I have an UIImage which i want to draw in UILabel, image load from json. I wanna save image before draw it. I've loaded image but i don't draw it, I think I saved the image problem. Here is my code: - (void)createDirectory { NSArray *paths =…
heaven
  • 221
  • 4
  • 19
0
votes
2 answers

getting the text up-side down in core graphic

I am drawing a text in core graphic by following - (void)drawRect:(CGRect)rect { CGContextTranslateCTM(context, 20, 150); CGContextScaleCTM(context, 1, 1); // Draw the text using the MyDrawText function myDrawText(context,…
tranvutuan
  • 6,089
  • 8
  • 47
  • 83
0
votes
1 answer

ios paint application overwriting paint strokes

I'm creating a paint application but if stroke one line one color and if stroke another line crossing the previous stroke the first stroke change color to the second color Here is the code I'm using to paint: - (void)touchesBegan:(NSSet *)touches…
Juan
  • 627
  • 2
  • 9
  • 27
0
votes
2 answers

how to change the default color of string during drawRect (), core graphic

I am drawing a string in rectangle using following method - (void)drawRect:(CGRect)rect { ................................................. ................................................. for(NSString *titleString in self.titlesArray)…
tranvutuan
  • 6,089
  • 8
  • 47
  • 83
0
votes
1 answer

How to prevent drawings to a UIView context from dissappearing?

I'd like to create a simple fingerpainting feature in my app. Problem is any drawings I do to my UIView subclass view instance are erased after each drawRect call... How do you go about preserving your context drawings in your UIViews?
RexOnRoids
  • 14,002
  • 33
  • 96
  • 136
0
votes
6 answers

Drawing with drawRect method - Cocoa

I've been looking for solutions but can't figure out if it is possible to do the following: I have a drawRect method, what i want to do is to add a graphic element (such as rects and lines) to the current view without refreshing it. I used to call…
Alberto
  • 4,212
  • 5
  • 22
  • 36
0
votes
2 answers

How to draw with few colors

He i'm working on simple pie chart, and i've got problem when i'm drawing it. I want to change color of every piece of pie chart, but when method drawRect: is called my pie chart is in signle color. How make it correctly? for (int i = 0; i < [values…
Tomasz Szulc
  • 4,217
  • 4
  • 43
  • 79