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

DrawRect of UIView inside UIScrollView

I'm trying to draw a small image on a UIScrollView for my iPhone app. I started with a UIImage created from a png I included in my bundle and that works ok. Every time the zooming/panning stops the delegate of the scrollview recalculates the frame…
Craig
  • 8,093
  • 8
  • 42
  • 74
4
votes
1 answer

Animating custom Bezier paths by looping drawRect

I have custom drawing code that uses bezier paths , gradients and strokes to perform my drawing. I want to run custom animations by looping drawRect and changing the values of properties on the bezier paths. I have looked at using CAShapeLayer…
Sagar
  • 555
  • 9
  • 24
4
votes
4 answers

UITableViewCell drawInRect iOS7

Hi I am trying to draw strings in my UITableViewCell in iOS 7 with the following code -(void)drawRect:(CGRect)rect{ [super drawRect:rect]; CGRect playerNameRect = CGRectMake(0, kCellY, kPlayerNameSpace, kCellHeight); NSDictionary*dictonary =…
Luke
  • 612
  • 1
  • 6
  • 19
4
votes
2 answers

How to draw dots in a semi - circle pattern

How can I draw dots in semi circular pattern in iphone programmatically?
Nassif
  • 1,113
  • 2
  • 14
  • 34
4
votes
4 answers

Force redraw of a UIView or CALayer on scale/transform

Say you have a UIView or a CALayer that does its own (vector) drawing, and you want it to remain crisp at any size, even when scaling the view or layer. How can I make it redraw when it is scaled with the transform property? Is the only way to do to…
Guillaume
  • 4,331
  • 2
  • 28
  • 31
4
votes
2 answers

iOS UITableView with dynamic text and images rendered together (NSAttributedString + images)

My problem is this: I have dynamic content in an iOS app (such as twits - although this is not a twitter app) that include both text and images (mostly icons/emoticons and thumbnails). I want to render both text and images together in a table row.…
cusquinho
  • 387
  • 1
  • 4
  • 14
4
votes
1 answer

Draw a pie chart with UIBezierPath

I'm trying to draw a PieChart using UIBezierPath, and I'm pretty close to do so, however, I've got a problem, as you can see on the screenshot attached Here's the code I'm using : -(void)drawRect:(CGRect)rect { CGRect bounds = self.bounds; …
4
votes
1 answer

collectionView:cellForItemAtIndexPath mixes up images, drawn with drawRect:

I decided to draw my UICollectionViewCell's with drawRect: instead of the custom xib files for performance (as I have shadows and label shadows). For some reason, since I changed this, my cells not draw with different images each time they are…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
4
votes
2 answers

Not able to include undo/redo with smooth free hand drawing

Struggling with issue since many days. Hope i can get an answer here. i have used this link to smoothen my free hand drawing. In this code i was able to set line width and color but i am finding it much difficult when i try to include undo/redo…
YogiAR
  • 2,207
  • 23
  • 44
4
votes
1 answer

Calling setNeedsDisplay in layoutSubviews?

Consider a view with a custom background that is drawn in drawRect:. If the view changes size, the background need to be redrawn. Is this a bad idea? - (void) layoutSubviews { [super layoutSubviews]; [self setNeedsDisplay]; } If it is, what…
hpique
  • 119,096
  • 131
  • 338
  • 476
4
votes
3 answers

How to create bubbles & arrows in iPhone help page about using buttons?

Most of the apps today provides the tutorial that teaches the user to how to use the buttons in the app. This help page is normally in black color with a little alpha value (so only the background will semi-visible) with a bubble box that contains…
Confused
  • 3,846
  • 7
  • 45
  • 72
4
votes
3 answers

Zoom with a drawing view

I'm looking for a solution in order to have a beautiful zoom on a drawing view. In my app, I have a view with an other UIView (which is used like a drawing view) and when I draw a stroke on it, the stroke is perfect. But when I zoom the view, I have…
4
votes
1 answer

Optimize CGContextDrawRadialGradient in drawRect:

In my iPad app, I have a UITableView that alloc/inits a UIView subclass every time a new cell is selected. I've overridden drawRect: in this UIView to draw a radial gradient and it works fine, but performance is suffering - when a cell is tapped,…
lobianco
  • 6,226
  • 2
  • 33
  • 48
4
votes
2 answers

Having trouble with releases in core graphics

I've just started with releasing in core graphics, so I might need a little help. I have code which looks like this: UIImage *buttonImage() { UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0); CGContextRef context =…
Andrew
  • 15,935
  • 28
  • 121
  • 203
4
votes
2 answers

drawRect causes slow scrolling even though it is not being called

In my app I have a scrollView with about 20 subviews in it. Each of these subviews has a drawRect method that at the moment looks like this: - (void)drawRect:(CGRect)rect { NSLog(@"drawRect called"); } When the subviews are added, drawRect is…