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

how to optimize drawRect?

The following is my self-defined view's drawRect, it draw a chess board, the board has 19*19 lines, and character a-t at top and bottom sides, 1-19 at left and right sides, also 9 dots: - (void)drawRect:(CGRect)rect { // Get the drawing context …
TieDad
  • 9,143
  • 5
  • 32
  • 58
0
votes
1 answer

Want to draw a Solid Circle/Dot only after tapping a button in cocos2d

I have just started to looking at cocos2d and much interested to learn. Basically i just want to draw a little solid circle (like a dot around 20 radius) where i touch the screen and it can only enable after pressing a button. How can i do this…
iUser
  • 1,075
  • 3
  • 20
  • 49
0
votes
1 answer

where to put drawrect method?

I am refering a tutorial from raywenderlich.all thins work perfectly , but in the last where i am customizing my text field,the tutorial says "Replace the call to super with the following code" - (void)drawRect:(CGRect)rect { UIImage…
user1541029
0
votes
2 answers

Single view iOS app with custom drawRect

I though I understood this, but I can't get it to work: I'm trying to create a very simple app, to test various things (OK - it's an app to estimate Pi using the Monte Carlo technique by simulating throwing darts at a board). I have a single view…
Steve Ives
  • 7,894
  • 3
  • 24
  • 55
0
votes
1 answer

Does calling [view setNeedsDisplay] for a view behind another semi-transparent view not invoke drawRect:?

I have two views: View A with alpha 1.0 View B with alpha 0.5 Both are subviews, with view B added as a subview after view A which implies that the opaque view A is partially visible through the semi-transparent view B. When I call setNeedsDisplay…
Sid
  • 9,508
  • 5
  • 39
  • 60
0
votes
1 answer

Cocoa Application does not redraw after overlapping another application

After I overlay an application over my previous application, I go back to previous application and encounter a few errors: certain components have disappeared only way to make the components visible is to resize the window that seems to redraw the…
Andy Jacobs
  • 15,187
  • 13
  • 60
  • 91
0
votes
1 answer

drawRect Optimization

I am working on an application that allows the user to select an image (camera or gallery), then draw on that image with their finger. The area that they draw becomes the transparent portion of a mask. A second image is then drawn below the first…
kevinstueber
  • 2,926
  • 3
  • 26
  • 26
0
votes
1 answer

CGContext donesn't work correctly in thread

I'm trying to make infinite drawing in custom UIView from another thread using Core Graphics. It's impossible to obtain current CGContext so I try to create a new one. But I have no idea how to apply it to the view. Here is the code I use in my…
Rafael Kayumov
  • 226
  • 1
  • 11
0
votes
1 answer

External Display drawRect issue

I have an app that displays the nodes of a connected graph. When the user touches a node I highlight the paths to the adjacent nodes by showing a clearColor "connections" view behind the nodes that is sized to contain the nodes of interest. This…
Fran K.
  • 866
  • 10
  • 23
0
votes
1 answer

How to redraw a certain rect in drawRect

Here is my problem. I am planning to draw 999 circles inside a view at the time of setup, which is done successfully in drawRect. After that, I am planning to edit the color of each circle when user touches (which i am handling using the tap gesture…
jeevangs
  • 306
  • 5
  • 20
0
votes
1 answer

How to change the Vertical Margin / Gap in UILabel line

I'm looking for a way to decrease the line gap in a multiline UILabel. This seems to be sort of mentioned here Objective C - UILabel multiline vertical gap height. But I wanted to be clear, before reinventing the wheel: See Here for example Any…
David van Dugteren
  • 3,879
  • 9
  • 33
  • 48
0
votes
1 answer

How to override the OnDraw Method?

I have an OnDraw method which draws a set of rectangles [ like an indoor map].On the touch event, a new Activity Intent is called.After the new activity is called,I want to know, how to redraw the rectangles on the buttonClick event( showing a new…
Ruby
  • 752
  • 2
  • 8
  • 23
0
votes
1 answer

check if image is already drawn on the context [iPhone]

I am using UIImage *image = @"some image" [image drawInRect:CGRectMake(50,50, 100, 100)]; How can i check draw image only if(cgrect(50, 50, 100, 100) doesn't have an image){ // only then draw the image }
user431791
  • 341
  • 2
  • 17
0
votes
1 answer

CoreGraphics: Draw rect in center of view

I have a UIView subclass with the drawRect: method overriden. In there, I have long lines of generated code that draw something. The generated code has a problem of having all the vertices/coordinates of the paths/lines hard-coded. So, to draw a…
Mazyod
  • 22,319
  • 10
  • 92
  • 157
0
votes
2 answers

How to open a new Intent inside OnTouch Event?

I have a customized OnTouch Method where i check if the touch coordinates contains a rectangle.After checking the condition i want to start a new Activity.But unfortuanlely its not workin.Can someone help me out? public class custom extends…
Ruby
  • 752
  • 2
  • 8
  • 23