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

UIView & Image Clipping in iPhone?

Let said I have a image which the circle in the middle is transparent and I use the drawRect function to draw sqaure like the second image below. Then what I want to do is to get the alpha layer of the first image, the circle as a path, then apply…
Sola
  • 1,512
  • 4
  • 15
  • 31
4
votes
2 answers

UIView with CATransform3D inside a UITableViewCell = Choppy Scrolling

I'm using a custom UITableViewCell, into which I am placing a subclassed UIView (within contentView, natch). The UIView in question displays a directional arrow and two lines of supporting text. The arrow is displayed by means of a layer with a…
Joe D'Andrea
  • 5,141
  • 6
  • 49
  • 67
4
votes
1 answer

Actionscript 3.0 drawRect works weird

I have a BitmapData object named myBitmapData. It was loaded of PNG of size 104x104. This PNG represents a red circle on the transparent background. There is also a Sprite object named myBackground. I want render that red circle into…
Nick
  • 3,205
  • 9
  • 57
  • 108
4
votes
1 answer

Does setNeedsDisplay have immediate effect or it is merely queued for later?

Does anybody here know whether setNeedsDisplay results in an immediate drawRect call and immediate updating of the screen? Or is it merely a queued request? Thanks.
Hupe
  • 41
  • 1
  • 3
4
votes
2 answers

Fill In UIView With Multiple Colors iOS

I'd like to fill in a UIView Background with multiple colors. I want to use it as a status bar of sorts, so if 1/2 the necessary steps are completed, the UIView Background will be 1/2 green and 1/2 red. When the user completes more steps (say…
Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196
4
votes
2 answers

NSView drawRect interfering with subviews?

I have an nsview and i use draw rect to draw an image for background. It also has 3 subviews nsbuttons. The problem is, whenever the mouse is down on a button, the other buttons disappear. But when I remove the draw rect method, this doesn't happen.…
user635064
  • 6,219
  • 12
  • 54
  • 100
4
votes
0 answers

UIKit setNeedsDisplayInRect: dirty rectangle not being respected

I'm working on an app where the user can toggle individual squares on and off in a grid that can potentially be hundreds of squares in each direction. I have a custom view that is drawing all the squares and is inside a UIScrollView's content view.…
Adam Evans
  • 2,072
  • 1
  • 20
  • 29
4
votes
1 answer

Problems rotating UIView with drawing inside

I want to rotate a UIView with a drawing inside (circle, rectangle or line). The problem is when I rotate the view and refresh the drawing (I need ir when I change some properties of the drawing, i.e) the drawing doesn't follow the view... UIView…
4
votes
3 answers

How will i remove UIBezierPath from the uiview on button click.?

I am working on digital signature on uiview. i create it normaly by this code, but i am not able to remove bezier path on button click.i am sharing my code PLease look at my code. #import "Signature.h" @implementation Signature { UIBezierPath…
sandeep tomar
  • 303
  • 1
  • 5
  • 17
4
votes
1 answer

UILabel Subclass - Custom 'drawRect' method causes text to cut off / not show

I am creating a simple 'tooltip' subclass that is a rounded rectangle and a small triangle that will be 'anchored' to another view. I created a UILabel subclass and am overriding 'drawRect' to shrink the main label area and draw a triangle. The…
JimmyJammed
  • 9,598
  • 19
  • 79
  • 146
4
votes
1 answer

Programmatically calling drawRect() in swift

I am fairly new to swift, and I had been doing all of my coding programmatically. I finally branched out and started learning some awesome things using the Interface Builder and what not. I have created some cool custom drawings in a UIView class I…
Pierce
  • 3,148
  • 16
  • 38
4
votes
3 answers

Is drawRect: called on multiple threads when using a CATiledlayer?

I know that drawLayer: and drawlayer:inContext: are called on multiple threads when using a CATiledlayer, but what about drawRect:? Apple's PhotoScroller example code uses drawRect: to get its images from disk, and it has no special code for…
Steve Weller
  • 4,599
  • 4
  • 23
  • 30
4
votes
1 answer

Draw transparent-to-white gradient over white in iOS

I have an iOS app with text on the main screen that scrolls. I want the text to fade out at the bottom of the screen. So I make a custom view and do something like this in drawRect: CGColorSpaceRef colorSpace =…
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
4
votes
0 answers

drawInRect withAttributes Crashing on iOS8 GM

UIGraphicsBeginPDFContextToFile(filePath, CGRectZero, nil); UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil); CGContextRef ctx = UIGraphicsGetCurrentContext(); UIFont *bigFont = [UIFont…
4
votes
2 answers

How to change individual square colour with respect to music per beats continuously for making a visualizer in IPhone?

I want to make a visualisation for my music player.so that i draw a grid view and i want to change each square colour randomly or continuously. My Code for draw grid - (void)drawRect:(CGRect)rect for (int i = 0; i < 4 ;i = i + 1) { for (int j…
iamVishal16
  • 1,780
  • 18
  • 40