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
1 answer

Drawing ruled lines in UITextView

In a UITextView I want to draw ruled lines along with the text. For that, I subclass UITextView and overwrite drawRect. Seing a few post on the subject (including on this site), that seems the right way to start. Here is the loop where I draw the…
Michel
  • 10,303
  • 17
  • 82
  • 179
0
votes
1 answer

Use of CoreGraphics Loop Draw Creating Performance Issues

I am interested in overriding drawRect in a subclassed UIView to create a simple textured background for a tableView. I have accomplished my goal, but the performance is not so great. I understand this is something of a common issue with newbies…
natenash203
  • 699
  • 6
  • 15
0
votes
3 answers

How to create a border around circle which is created using drawrect method in iphone

Hi in one of my application i had created a circle using drawrect method on UIView object.Now my concern i want draw a highlight border around the circle for that actually i used myView.layer.borderWidth =3.0; myView.layer.borderColor=[UIColor…
Naresh
  • 363
  • 1
  • 18
0
votes
1 answer

Set background color of NSView with negative bounds origin

I am currently trying to set a background color/pattern for an NSView that has a negative bounds origin. The problem is, that it only colors parts of the view (those where x>0 && y>0). I understand, that I have to draw the background in the…
Tim Bodeit
  • 9,673
  • 3
  • 27
  • 57
0
votes
1 answer

iPhone - draw a transparent (cleared) rectangle with customized border

I'm trying to draw a rectangle, which should have black color border of width 5.0, I am getting the rectangle as seen below, CGContextRef context = UIGraphicsGetCurrentContext(); CGContextStrokePath(context); CGContextSetRGBFillColor(context, 0.0,…
Hemang
  • 26,840
  • 19
  • 119
  • 186
0
votes
1 answer

drawRect not called on PDFView subclass

I have a custom PDFView subclass and have overridden -mouseDown, -mouseDragged etc to draw a rectangle over the view. Here is the code I am using: @implementation MyPDFView { NSPoint clickLocation; NSRect selection; } -…
colincameron
  • 2,696
  • 4
  • 23
  • 46
0
votes
0 answers

Draw minimal with drawRect and setNeedsDisplayInRect

He, I just realized that [self setNeedsDisplayInRect:(dRect)] draws everything (and not only the necessary) and then updates the screen in "dRect". So I started to edit the drawRect-method like this: - (void)drawRect:(NSRect)dirtyRect{ if…
fw2601
  • 83
  • 6
0
votes
1 answer

DrawRect keeps drawing white background

//inside init _color = [UIColor orangeColor]; self.backgroundColor = [UIColor clearColor]; self.clearsContextBeforeDrawing = NO; //inside drawRect CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSaveGState(ctx); …
Yogurt
  • 2,913
  • 2
  • 32
  • 63
0
votes
1 answer

drawRect and AFNetworking

I'm using the following code self.imageView = [[UIImageView alloc] init]; [self.imageView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"profile-image-placeholder"]]; [self setNeedsLayout]; [self…
sger
  • 719
  • 2
  • 12
  • 26
0
votes
1 answer

ontouch in android-draw rectangle

in my application on touch event i want to drawrectangle-i tried this.butnot getting exactly how to draw.please help me. i want to draw rectangle on points where is touched. how can i use getX() and getY() in drawRect() method? below is code- public…
yuva ツ
  • 3,707
  • 9
  • 50
  • 78
0
votes
3 answers

Losing all drawing when app comes in foreground

I am drawing with multiple colors by dragging fingers on the iPhone app but when I minimize the app and then maximizes, I am losing all my drawing as it calls the drawrect method. I don't know from where this method is being called but I am not able…
Developer
  • 6,375
  • 12
  • 58
  • 92
0
votes
1 answer

Scrolling with two finger gesture

I have a drawing view on a UIScrollView. What I want to do is draw lines with one finger, and scrolling with two fingers. The drawing view is to draw lines through touchesMoved as below. - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent…
Ryan
  • 4,799
  • 1
  • 29
  • 56
0
votes
2 answers

Capture UIImage of UIView stuck in DrawRect method

I am trying to capture image of my UIView but when I call this method - (UIImage *) imageWithView:(UIView *)view { UIGraphicsBeginImageContext(view.bounds.size); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * img…
Mashhadi
  • 3,004
  • 3
  • 46
  • 80
0
votes
2 answers

drawRect not being called on added subview

I'm trying to programmatically create a window with custom contentView and one custom NSTextField control, but i'm having trouble getting this hierarchy of window and views to draw themselves. I create a custom borderless window and override it's…
Eimantas
  • 48,927
  • 17
  • 132
  • 168
0
votes
1 answer

Quartz Drawing While Scrolling Issue

I have a subclass of UIView which I draw a graph on it. GraphingView.h @interface GraphingView : UIView ... @end I draw things here: GraphingView.m - (void)drawRect:(CGRect)rect { ... } Then, from another controller, I call this graph by just…
lnguyen55
  • 737
  • 6
  • 16