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 can I determine the minimum NSRect for drawing an attributed string?

I cannot seem to find this and hope it is a FAQ somewhere. How can I get the minimum NSRect needed to draw an NSAttributed string on OS X? I am doing an overlay borderless window, but I want to constrain the size based on what is needed to display…
uchuugaka
  • 12,679
  • 6
  • 37
  • 55
0
votes
0 answers

Drawing straight lines when touched moved IOS

I have planned to do simple drawing up, using that use can draw straight lines and free hand drawing, based on the selection it change. But the problem is straight line gets repeated from the starting point more than 10 or 15 lines when i try to…
Manikandan
  • 107
  • 2
  • 12
0
votes
2 answers

drawRect being called but the code within it not being executed when run?

I had chosen the single view application template from XCODE 4.5.2. I have an appdelegate , a viewcontroller with a RDViewController.xib which I had made a type of my UIView class Graphics. Also I have Graphics.h and Graphics.m (drawRect Method in…
ShaluRaj
  • 67
  • 6
0
votes
1 answer

Using drawInRect inside a c method not working

I have this code, to draw some text inside a (so far) simple button: UIImage *buttonImage(CGRect bounds, UIColor *fillColor, NSString *title) { UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0); CGContextRef context =…
Andrew
  • 15,935
  • 28
  • 121
  • 203
0
votes
1 answer

iOS Draw custom view with bottom border

I have a custom UIView that I would like to manually draw in the drawRect: method. I want the view to be a black rectangle with a single rounded corner and a red border on the bottom only. How can I implement drawRect: to draw this view?
0
votes
1 answer

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…
Ali Awais
  • 113
  • 1
  • 9
0
votes
1 answer

Subclassing UIToolbar and overriding drawRect: - UIBarButtonItems NOT displaying

Context I'm using the 'initWithNavigationBarClass' method to initialize a UINavigationController with a custom toolbar, here is the line where I alloc init the UINavigationController navigationController = [[UINavigationController alloc]…
drc
  • 1,905
  • 4
  • 22
  • 28
0
votes
1 answer

picture does not move ( -setNeedsDisplay:YES does not call drawRect:)

sorry for bothering you again about the - (void)setNeedsDisplay which does not call - (void)drawRect: method...but I spend so much time on this problem I am a beginner in Objective-C and I am trying to do a simple shoot-them up. (I know I need to…
0
votes
2 answers

setNeedsDisplay has not been called

I draw an sine wave on an UIView by using drawrect and it is linked to an UIViewController. It can draw one time when i first load the viewcontroller. I want that when I change the value of a UISlider in the ViewController,it change the frequency…
IvyBB
  • 60
  • 7
0
votes
0 answers

Drawing a triangle in UIView

I've got a triangle and I am trying to draw via drawRect in a UIView, Everything seems to work for the most part, except when I attempt to draw a triangle that exceeds the bounds of the view. I don't think i am taking the right approach, I am…
Joe Million
  • 147
  • 9
0
votes
2 answers

DrawRect: How to fill in polygon given an ordered set of points?

Currently in my drawRect: method I am drawing a line between every point in my set of points, each represented as a CGPoint; however, now I would like to fill in the area that is within the region of these set points. I cannot figure how to do this…
jab
  • 5,673
  • 9
  • 53
  • 84
0
votes
1 answer

IOS 6 Custom UIView by paintcode

I am an IOS beginner. I am trying to show a custom button with code generated by paintcode. I drag a View on Storyboard then set this generic view class to my custom view "GreenButton". When I run the app, the button does not show up. I added…
Timuçin
  • 4,653
  • 3
  • 25
  • 34
0
votes
3 answers

setNeedsDisplay no refresh the screen

Iim displaying a huge amount of images each time I call drawRect with setNeedsDisplay. The problem is that cause lags cause each time I call dracRect, I redraw every images (thousands). Is there a way to not redraw all the images. I mean, keep all…
0
votes
1 answer

How to erase lines drawn in drawrect ?

I have an UIView BoardView in which I draw lines. When I push a cell in a table view, I draw a line in BoardView. When I push the first cell everything is ok, the lines is drawn. Now, if I push a second cell, I would like erase the first line and…
cmii
  • 3,556
  • 8
  • 38
  • 69
0
votes
1 answer

Triggering drawRect from a Timer

I am fairly new to Xcode but not new to programming. I am using XCode 4.6.1 using Storyboard creating an App to run on an iPad. I am not familiar with NIBs ,only Storyboard. My MainViewController needs two functional areas - A graph that is…