drawrect

Calling setNeedsDisplay on a UIView from another class

I have a UIView subclass that I manipulate a lot of graphics on based on touches. All the [self setNeedsDisplay] calls seem to be fine. However, I used an instance variable pointer to my same UIView subclass instance, and then tried manipulating it and then calling [UIViewSubClass setNeedsDisplay] from another UIView class, and DrawRe...

iPhone: why isn't drawRect getting called?

Okay, I guess I'm missing something important, and I can't seem to find the answer. I'm posting all the code, because it's very small. Can someone please tell me what I'm doing wrong? I've worked on this looking at example after example, for quite a while, and nothing I do seems to work. When I create the app, I use whichever skeleto...

Can I use DrawRect on a UIImageView loaded from a NIB?

I've created a NIB file with some button controls on it, and as a background it has an ImageView which contains a PNG file loaded from my project. What I want to do is to draw on top of the ImageView - imagine that my UI is a clockface and I want to draw the hands of the clock on top of the background image. Is it the correct approach ...

How to draw a default image in imageview in the center of imageView?

How to draw a default image in imageview in the center of imageView?using - (void)drawRect:(NSRect)rect overridden method of NSImageView ...

How to prevent drawings to a UIView context from dissappearing?

I'd like to create a simple fingerpainting feature in my app. Problem is any drawings I do to my UIView subclass view instance are erased after each drawRect call... How do you go about preserving your context drawings in your UIViews? ...

Reference to Model data in a view instance drawRect

Another newbie question : I have a simple iPhone app with a model, a controller and a view class. I want to draw a rectangle in the view using variables from the model (like the size or the position) What is the best way to make reference inside the drawRect method code, to variables from the model instance ? (the model is instanciate...

Weird anti-aliasing in custom view

I have a custom UIView which is drawn using its -[drawRect:] method. The problem is that the anti-aliasing acts very weird as black lines horizontal or vertical lines are drawn very blurry. If I disable anti-aliasing with CGContextSetAllowsAntialiasing, everything is drawn as expected. Anti-Aliasing: No Anti-Aliasing (which looks li...

Custom Drawing of Alpha Images

Hello, I am trying to do custom drawing of an image(with alpha) and eventually going to apply different color tints to it. Right now I am just trying to draw it correctly. This might be simple problem but the result is the ALPHA on my image is black. Image is .png created from photoshop with correct alpha. - (void) drawRect:(CGRect)area...

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 setContentView / contentView accessors. This seems to work fine and custom contentView's in...

UIView. How do I redisplay a "data driven" UIView?

I am doing a scientific visualization app for iPhone. Periodically a UIView subclass will receive some data from the network that it must render via its overridden drawRect: method. My challenge is that there is no way to indicate to Cocoa-Touch that this data has arrived - or changed - other then [myView setNeedsDisplay] which is ignor...

iphone pinch zoom

I have drawn few shapes in drawRect function of a view, these shapes color changes after some time repeatedly using setNeedsDisplay that calls the drawRect, secondly a shape name is also to be selected when tapped on it, up till now all works fine. There are three views each having more than one shapes drawn as above. All these views ar...

How to draw an UIImage or directly in -drawRect:?

I have an UIImage which I want to draw on a UIView. But instead of creating an UIImageView and adding this as an subview, I want to overwrite -drawRect: and draw my UIView directly. For example, my code looks like: - (void)drawRect:(CGRect)rect { CGContextRef myContext = UIGraphicsGetCurrentContext(); UIImage *img = [UIImage i...

iPhone custom drawn UITableViewCell , how to load + insert images from the web in a thread?

Hi. I've been drawing custom table cells (using the samples from apple as a base) and have now come to having to do a cell which displays an image from a URL - each cell would have a different image (based on some data it has) but all the cells are the same and so the same reuse id. What's the correct structure for doing this? Obviously...

Redrawing NSCollectionView on Scroll Causes Breakup of Graphics

I have a minor irritant in an NSCollectionView in which the NSCollectionViewItem's break up visually when I scroll the window. The rate of breakup depends upon the rate of scrolling. For example, if I scroll slowly the breakup occurs more often. Fast scrolling less so. It appears that the problem is when the custom NSView of the NSColle...

Where to place drawRect?

I am just starting to learn drawing procedures for the IPhone, but something confuses me. If I start a new view-based application, and establish a new view class, associate that with the view that came with the application, then drawRect, placed in that new view class, seems to work. But why can't I just establish my drawing routines...

iPhone + UIView. Enormous memory consumption during drawRect. Any strategies for reducing this?

My data visualization app incurs a large memory consumption spike during redraw (setNeedsDisplay which triggers drawRect). I am currently redrawing the entire view that houses the data plot. This view is much larger then the device display. Is there any way to tell CoreGraphics to allocate just enough memory to draw each element (each e...

How I force a "container" UIView to have no CALayer?

I am trying to conserve memory consumption in my visualization about. I have a scrollView with a containerView that contains some child views. I would like to eliminate the CALayer of the scrollView and containerView. So, just the child views consume memory during redraws, etc. How do I do this? Thanks, Doug ...

iPhone Quartz. How do I create a matte using a path rather then a bitmap?

In the visualization app I'm writing I want to shape a graphic using a matte created with a path. The graphic is a horizontal rectangular strip with various shapes drawn within. Atop this rectangular strip I want to draw an ellipse to act as a matte that shapes the rectangular strip to make it appear to drawn within the ellipse. How do I...

Drawing squares on Flex Canvas

I'm trying to write some code to an animated images of squares on a Flex Canvas. There's something wrong with my code below because it becomes progressively slower. I assume I'm supposed to clear the old squares or something. What am I doing wrong below?: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.ado...

Static images in drawRect or in reuse cell method?

Hi, I was testing adding a static image in an reused cell vs drawing it in the cell with drawrect method. I tested both methods and it seems drawing the image every time the cell gets in display is faster then adding the image to an reused cell. Anyone knows, how this is possible? i have two more static images, should i draw these in d...