drawrect

How to move a line ? xcode

Hi all, Would appreciate any ideas. I have a line (begin x,y / end x,y). Its stored in an array. I can detect a touch that intersects my line (can delete etc; from array). What I would like to do now is to move that line to new location (based on drag), or, continue the line further (or indeed reduce its length) at either point. All base...

Why is drawAtPoint Creating Duplicate Images in my tablecell's contentview?

I have a view with a custom slider. We are using a subclass of TableViewController that is generating instances of UITableViewCell. Inside each tableViewCell we add our custom slider (a UI View) as a subview. In here we have a view that serves as the slider's control knob. It is just a subclass of UIView with a gesture recognizer. The dr...

UIScrollView redrawing content while scrolling?

I know there is a property or method that makes the scrollview/uiview call drawRect: method while is scrolling. By default is disabled because of performance reasons but I need to enable it. I cannot remember the name of the method hence I cannot look for it, anyone who knows what I am looking for? Thanks in advance ...

drawRect (+setNeedsRedisplay) fills wil unwanted color, slowing iPad down

My iPad application is very simple: There's a Window, with a child View of class ContextView (my own) ContextView's background (as definied in Interface Builder) has a green background, and is Opaque. Clear Context Before Drawing is off (for both Window and UIView.) CADisplayLink selector calls setNeedsDisplay once a frame update. The ...

What happens in the system when canvas.drawBitmap is called?

I have a scrollable and zoomable map which has a low res copy of the map which is drawn when the zoom scale is small and a tile system when the user zooms in past a certain point. The problem im having is that the very first time the tiles are drawn there is a short, but noticable lag. After that initial lag everything is smooth. The GC ...

subclassed UITableViewCell - backgroundView covers up anything I do in drawRect

I'm trying to make a subclassed UITableViewCell where I draw an image in the upper right corner. I have it working perfectly - except when I set self.backgroundView, my background image covers up the image drawn in drawRect. There must be a way to be able to set a background image (and the selectedBackgroundView) without covering up wha...

MKAnnotationView drawRect: not getting called

I've implemented a custom annotation derived from MKAnnotation called ContainerAnnotation and a custom annotation view derived from MKAnnotationView with a drawRect: method called ContainerAnnotationView. For some reason the drawRect: method is not getting called and I can't figure out why. Here's the source code for my annotation view...

UIView drawRect drawing lines

Hi, I'm trying to add a little red line on the bottom of my UIView. I want the line to be a 1px line. Can someone tell me why the following code: - (void)drawRect:(CGRect)rect { CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextSaveGState(currentContext); CGContextSetRGBFillColor(currentContext, 0.0f, 0.0f, 0.0f, 1...

How UIView "drawRect" puts contents into it's "layer"?

Hi all, I have read lot of articles to use either "drawRect" or "drawLayer" functions for custom drawing. However, I haven't been able to make out how iOS or Cococa converts drawing placed in "drawRect" (UIView) to it's own layer (UIView.layer) contents? Urgent help required Regards Mohit ...

Quartz custom drawing and UIViews. Cannot see the quartz drawing.

Hello everyone, I am drawing on a UIview several other subviews. Then in the DrawRect method of this UIView I am drawing a bezier curve. UNFORTUNATELY, the bezier curve never shows up. I have checked that the bezier curve is behind the background of the view (when I remove the background view I can see it). How can I combine custom dr...

drawrect Vs layoutsubvies - NSView - Cocoa touch

Hi, I can't find a decent answer to explain me the difference between these 2 functions. when does every one gets called, and how does one different then the other ? for example , can't I just layout my views inside drawrect ? Thanks ...

iPhone: Resizing in drawRect:

Hi all, I have a UIView based control which I need to resize depending on various criteria and properties of the control. I'm not sure if the way I'm doing it is the best way but so far it's the only one I've found that seems to work. Because the size of the control is dependant on various properties, I cannot set the size in a construc...

I am not able to draw shapes except for random lines onthe canvas. What will be the code for other options eg any line, rectangle or a triangle?

<script type="text/javascript"> var canvas, context, tool, e; var varblurup=0; var varsizeup=1; var swtchclr; // Keep everything in anonymous function, called on window load. if(window.addEventListener) { window.addEventListener('load', function () { //check tool is pen or line or shape var chktool="pen"; function in...

CGContextSetRGBFillColor is not setting the good color.

My problem : the color of the fill in square go from black to full blue (255) with no transition color (darkest blue, dark blue, blue...). It seems that the CGContextSetRGBStroke is additive (WTF Oo) . like if the blue was 14 and the next update I put 140 the blue will be 154 and not 140 has I set. Is someone get that problem ? in the ...

what is the difference between UIImageView and drawInRect?

Hi, I want to display so many images in table cells. I knew two methods to show an image. One is creating an instance to UIImageView and show it CGRect rect=CGRectMake(x,y,width,height); UIImageView *image=[[UIImageView alloc]initWithFrame:rect]; [image setImage:[UIImage imageNamed:@"sample.jpg"]]; Another method is, CGRect rec...

UIView CGGradient clipped to drawn "frame"

Hi all! I'm trying to make a more sophisticated drawing of a UILabels (or a UIView, putting the UILabel on top, should that be required) background. Since I want this to resize automatically when the user changes iPhone orientation, I am trying to implement this in a subclasses drawRect function. I would love to be able to tune this all...

UIView subclass creating its own UIButtons

Hi all, I have subclassed UIView so I can draw some lines in it. In this UIView are a whole bunch of buttons which I decided to create as a method that drawRect calls after the lines are drawn. It works but sometimes only part of the button renders. If i remove the button creation and instead add the UIButton in the subclassed UIViews p...

Custom UITableViewCell and animation on setSelected:animated:

I have a UITableViewCell subclass that does its drawing in a drawRect: method. The whole rectangle is custom drawn, including the background. I was able to get very complex cells while keeping the scrolling very smooth. My problem: I call [table deselectRowAtIndexPath:path animated:YES]; whenever the view appears, in order to comply wit...

[self setNeedsDisplay:YES] crashes?

when I try to run [self setNeedsDisplay:YES] in my ViewController it crashes with unrecognized selector sent to instance... is there something I'm doing wrong? I'm using: -(void) drawRect: (CGRect)rect { ///code... } ...

Adding outline shadow to a UIView which is iOS 3.0 compatible

Hello guys, I have two UIViewControllers A and B and they are added as subviews in the AppDelegate with B on top of A. When a UIButton on B is tapped B slides off to the left with the following code: [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [...