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
1
vote
0 answers

UIView subclassing - how to block default drawRect method

I have the following task. I have set up a UIView in InterfaceBuilder and set it my own UIView subclass which I use do draw this view with rounded corners and a line around it. What I want to have, is to layout my view in interface builder: set…
BartoNaz
  • 2,743
  • 2
  • 26
  • 42
1
vote
1 answer

iOS/Xcode -- drawRect: Not Being Called in UIView Subclass

I'm working on an app with the main view being a UITabViewController. Under the UITabViewController are three UIViewControllers and one UITableViewController. Under one of the UIViewControllers is a UIView and an NSObject which conforms to…
1
vote
1 answer

Drop Shadow in DrawRect

I made this cool pie chart and now I'd like to drop a shadow under it. Is there anyway I can do it with DrawRect ? I'd like to do it right under the pie chart (drawn using DrawRect). Suggestions are welcome
Farini
  • 923
  • 1
  • 18
  • 35
1
vote
1 answer

Line not being drawn on all uitableviewcells

I have a table view with a custom cell (governed by a custom class of course) that has the following drawRect: function in the custom class: - (void)drawRect:(CGRect)rect { [super drawRect:rect]; CGRect busNumberFrame = busNumber.frame; …
pedroremedios
  • 763
  • 1
  • 11
  • 39
1
vote
2 answers

Trouble drawing CoreGraphics lines in drawRect() method

I'm working on the Stanford CS193p course and am trying to draw a graph. Drawing the axes works, but I can't draw the graph itself. I'm getting the message CGContextAddLineToPoint: no current point. when I try to draw. Here's the code. -…
MaxGabriel
  • 7,617
  • 4
  • 35
  • 82
1
vote
2 answers

How to get context of a CALayer plus a few pixels around it?

I am creating a layer with a shadow effect. Instead of adding it as a sublayer to my view's layer, I would like to draw it. But I am having problems being able to draw it with the shadow effect. The problem is that the context size it based on the…
runmad
  • 14,846
  • 9
  • 99
  • 140
1
vote
1 answer

UIBezierPath slow performance if used along with CGContextSetShadowWithColor

I am developing an app in which user draws lines with finger touch or simply sprays colors. I am using UIBezierPath to paint the path (colors) on finger touch in drawRect method with following code. CGContextRef context =…
infiniteLoop
  • 2,135
  • 1
  • 25
  • 29
1
vote
0 answers

Draw NSImage while space switching?

Currently in my project i've a simple nsimage which is updated via drawRect function. I need to change the nsimage when the user switches between spaces... so i set my new image and called setNeedsDisplay when the…
MajinBuu
  • 56
  • 3
1
vote
0 answers

UIView drawRect EXC_BAD_ACCESS on Recreate a Custon UIView

I having some problems with drawRect and create a new instance of a UIView custom class. My question is: How can i use of drawrect? I created a UIViewController with a UIScrollView and inside this UIScrollView about 50 UIViews. Each UIView create…
1
vote
1 answer

iOS drawRect: is it possible to clear the Graphics Context?

I'm writing an iPad app and I have a custom view where I override drawRect to do a bunch of drawing. I have a timer calling the setNeedsLayout to refresh the graphics. When I profile my application I see that the memory taken up by the application…
onetamer
  • 73
  • 6
1
vote
2 answers

How do I make a rectangle move in an image?

Basically I have an image loaded, and when I click a portion of the image, a rectangle (with no fill) shows up. If I click another part of the image again, that rectangle will show up once more. With each click, the same rectangle should appear. So…
alicedimarco
  • 325
  • 1
  • 5
  • 20
1
vote
0 answers

iOS: draw circle like in calendar app

I want to have custom table cells in my table view, that contain a colored circle as seen in the calendar app of the iOS devices (the one where you select the displayed calendars). Right now I made a custom cell that is having an UIView-sublass…
user944943
  • 113
  • 1
  • 2
  • 9
1
vote
1 answer

When to change the frame size of a UIView while custom drawing it?

I am doing a custom draw in my App for a View in drawRect method. I capture user's pinch gesture and based on that, I wanted to alter the the frame size of the View each time I do that. I tried changing the UIView's frame in drawRect method. But I…
RK-
  • 12,099
  • 23
  • 89
  • 155
1
vote
3 answers

Any possible way to call drawRect from a UIViewcontroller class?

I have a UIViewController class called AppController.h, AppController.m. I have thousands of lines of code in there, and that is the only reason why I didn't test this before I asked it. Is there any possible way to use drawRect in a…
Aspyn
  • 647
  • 1
  • 10
  • 25
1
vote
2 answers

Is drawrect more efficient for coregraphcs drawing than using core graphics in touches moved?

My whole app uses touchesMoved for drawing (Coregraphics). Should I be calling [self setNeedsDisplay] from within touchesMoved instead of performing the drawing code in there? Would that stop some lag that I am experiencing? The only reason I didn't…
Aspyn
  • 647
  • 1
  • 10
  • 25