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
2
votes
2 answers

Need to override drawrect if your UIView is merely a container?

According to Apple's docs, "Subclasses need not override -[UIView drawRect:] if the subclass is a container for other views." I have a custom UIView subclass that is indeed merely a container for other views. Yet the contained views aren't getting…
Greg Maletic
  • 6,225
  • 8
  • 54
  • 73
2
votes
1 answer

Performance issues pertaining to drawRect in iOS on Swift

Thank you for taking the time to read my thread. Recently i’ve been developing a simple iOS free-draw app and have run in to an issue that’s currently above my skill level to solve. I’ve been scouring the internet for days to try and come up with a…
2
votes
1 answer

swift is slow at updating view after a REST POST request

I'm sending some POST request to my sever with swift, the usual: let request = NSMutableURLRequest(URL: url) request.HTTPMethod = "POST" request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding) let task =…
matt
  • 2,312
  • 5
  • 34
  • 57
2
votes
0 answers

Printing the Content of an UIView with AirPrint results in Empty Page

I want to print the content of an UIView with an AirPrint printer. The UIView is drawed programatically with the drawrect: message and shown on the iPhone or iPad display. The printed image should fit into a default page so it will be different from…
Gabriel
  • 21
  • 4
2
votes
0 answers

iOS drawRect and cornerRadius. How does it work?

I don't understand why a simple view, with only cornerRadius property set to an arbitrary value, works perfectly, while as soon as i override drawRect ( also trying to call super.drawRect() ) cornerRadius doesn't work anymore. The solution is to set…
diningphil
  • 416
  • 5
  • 18
2
votes
2 answers

UIBezierPath drawing takes up 100% of CPU

I have a UIBezierPath is drawn on the screen every time the user's touch is moved. This works fine on my simulator on a Mac Pro, but as soon as I moved it to a physical device, the drawing began to lag a lot. Using instruments, I checked the CPU…
Liftoff
  • 24,717
  • 13
  • 66
  • 119
2
votes
2 answers

Multiple Rectangle drawing programmatically

I am trying to draw this kind of rectangle but i am unable to do it. I tried to put inside of a loop but id does not show anything. My code snippet is below: public class MainActivity extends ActionBarActivity { DrawView…
Omar Faroque Anik
  • 2,531
  • 1
  • 29
  • 42
2
votes
0 answers

Why is CGContextSetFillColorWithColor preferred over CGContextSetFillColor?

Apple recommends using CGContextSetFillColorWithColor instead of CGContextSetFillColor. CGContextSetFillColor ... The current fill color space must not be a pattern color space. For information on setting the fill color when using a pattern color…
dfdumaresq
  • 1,618
  • 4
  • 17
  • 22
2
votes
1 answer

Why is drawRect leaving parts of image?

Here's my case: I have a table which contains a list of restaurants, each entry shows the results of inspections over time on a scorebar that is drawn using drawRect. When the user scrolls the table down and then up, so that scorebars with yellow…
dfdumaresq
  • 1,618
  • 4
  • 17
  • 22
2
votes
1 answer

How to draw an open ended triangle with a specific angle in an UIView?

I'm stumped here and need some assistance with this. For testing purposes I have a UIView that I draw into via drawRect (code below). I'm able to draw a circle with an specific angle and such but it's filled and closed. I need it to be open and…
0SX
  • 1,252
  • 6
  • 24
  • 47
2
votes
1 answer

drawRect in SKScene

I am trying to use a UIBezier path for drawing a line using user touch. I have the physics body and bezier working separately although I need to merge them together. Is there a way to implement drawRect or an equivalent within SpriteKit? Thanks in…
user3339697
2
votes
1 answer

Drawing beyond a UIView's bounds

I'm trying to draw a complex border around a UIView in it's drawRect method using core graphics. The border is being clipped because it's outside of the view's bounds. Is there any way to prevent this clipping? Setting clipsToBounds to NO doesn't…
Darren Findlay
  • 2,533
  • 2
  • 29
  • 46
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
2
votes
1 answer

Place text on top of other CALayer in drawRect

I am trying to show text above CALayer but somehow I am not able to achieve it. I have used following code: - (void)drawRect:(CGRect)rect { self.layer.sublayers = nil; CGContextRef ctx = UIGraphicsGetCurrentContext(); …
Faisal Ali
  • 1,135
  • 10
  • 17
2
votes
2 answers

How to continue to drawRect: when finger on screen

I have the current code: - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { self.objectPoint = [[touches anyObject] locationInView:self]; float x, y; if (self.objectPoint.x > self.objectPoint.x) { x =…
Scott
  • 1,154
  • 1
  • 12
  • 25