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

How to create Clickable Rectangles?

Im drawing an indoor map using DrawRect method. I want to identify each rectangle by the user's OnTouch Event.How can i make it happen? I want to know if i can use the drawn Rectangles as independent objects Where i can identify them…
Ruby
  • 752
  • 2
  • 8
  • 23
0
votes
1 answer

issue raised when adding a rectangle to the uiview

I am drawing an rectangle using tutorial at here FlagClass.m -(void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); …
tranvutuan
  • 6,089
  • 8
  • 47
  • 83
0
votes
1 answer

drawRect or UIImages for UI elements?

I'be created several apps in the past by just making UI elements in Photoshop. However I recently discovered PaintCode and am wondering how much "better" it is to create the entire UI with UIView and UIButton subclasses and draw them in drawRect. If…
rnystrom
  • 1,906
  • 2
  • 21
  • 47
0
votes
1 answer

NSView's drawRect doesn't get called after CIFilter is applied under 10.8 only

I have an NSView (lets call it mainview) with a few subviews. One of these subviews has a time based (called via a timer) animation which is done in its drawRect method. Also I have some CIFilter effects applied to the mainview. All works as…
0
votes
0 answers

How do I add UIButtons to my custom view (cutom drawRect)

This iOS5+ project is using storyboard and ARC is ON. I'm making a custom view with a 'circle' inside (which will reprent a click, that'll just be a backgroundimage) and I need to draw circle segments inside (which I'm already doing in my drawRect)…
Spyral
  • 760
  • 1
  • 12
  • 33
0
votes
2 answers

setNeedsDisplay will not call drawRect

Important: I had figured out the problem but a moderator deleted it for some reason: I tried calling the function directly from the button instead of having the function in the view controller. I still don't fully understand why it didn't work, so I…
WolfLink
  • 3,308
  • 2
  • 26
  • 44
0
votes
1 answer

Custom UIProgressView drawing weirdness

I am trying to create my own custom UIProgressView by subclassing it and then overwrite the drawRect function. Everything works as expected except the progress filling bar. I can't get the height and image right. The images are both in Retina…
Saeverix
  • 397
  • 5
  • 18
0
votes
2 answers

CoreText with images

I want to add image in UIView using coreText and then text around image like below. eg.. Baaa img aaaa aaaa aaaaaaaa aaaaaaaa aaaaaaaa I want something like this where "img" is an image..and text start from "B".. thanks..
AVJ
  • 144
  • 14
0
votes
1 answer

Drawings in drawRect not being displayed correctly

I want to implement freeform drawing in my app. First, I tried the code inside drawLayer:inContext: and it gave me the result I wanted. Drawing in CALayer: But when I decided to implement the code inside drawRect:, this happened: Even if I draw…
Anna Fortuna
  • 1,071
  • 2
  • 17
  • 33
0
votes
2 answers

Drawing multiple rectangles in a view without using drawRect:

I have this code which makes multiple rectangles in a UIView: CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(ctx, 0.5); CGContextSetStrokeColorWithColor(ctx, [UIColor blueColor].CGColor); //newView.xPoints is always equal…
user1412469
  • 279
  • 5
  • 17
0
votes
1 answer

Triggering a redisplay upon date change

This is probably an easy question, but I'm a newbie, so I'm drawing a blank. I have a 2D graphical application whose graphics (implemented in drawRect) depend upon the date. When the date changes, the graphics change, so I figure I need to…
Victor Engel
  • 2,037
  • 2
  • 25
  • 46
0
votes
1 answer

UIView drawRect: performance in Augmented Reality App

i'm building an augmented reality app right now, but having some troubles with drawrect: of my UIView. First of all i'll show you my code: - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); for(AREALocation *loc…
Philip
  • 112
  • 14
0
votes
1 answer

Speed up or optimize persistent drawrect

I'm using the following code to create a persistent DrawRect for a finger painting type exercise When I run on the simulator it is fine, when I run on the iPad it gets delayed turning curves in jagged lines Please can some one help optimize or…
BarryF
  • 77
  • 1
  • 10
0
votes
1 answer

erase a persistent drawRect

I at last managed to get DrawRect that did not clear all the time using (I also have the setClearsContextBeforeDrawing:YES ) - (void)drawRect:(CGRect)rect { UIGraphicsPushContext(drawingContext); CGImageRef cgImage =…
BarryF
  • 77
  • 1
  • 10
0
votes
1 answer

drawRect: is not always called after setNeedsDisplay:YES when parent view is layer-backed

I have a basic Cocoa app with a custom NSCollectionView that overrides drawRect: to draw a red background (for illustration purposes). I noticed that at seemingly random times, drawRect: would not be called although I invoked setNeedsDisplay:YES.…
Mark
  • 6,647
  • 1
  • 45
  • 88