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
2
votes
2 answers

Questions regarding drawing in iOS

I want to create a little navigation bar on the bottom of my iPhone screen where I basically just draw 5 rectangles next to each other. However, only the active page should have the opacity of 1.0 and others should be slightly transparent…
the_critic
  • 12,720
  • 19
  • 67
  • 115
2
votes
3 answers

UIImage Resize drawRect Filling Background with Black

I have a class called MNTRectangle which is a subclass of UIImage. I have overridden the drawRect method of this class to draw a border on the image (using its frame). I have it so when the user starts a panning/dragging gesture on a class called…
user1331999
2
votes
1 answer

Animation not play with UIIView subClass (DrawRect method)

I have a view with a Tap gesture recognizer. When I touch it, there is an animation which modify the background color. My problem is that when i subclass my view to override the drawRect method my animation doesn't play anymore... How i can fixe…
Jonathan
  • 873
  • 3
  • 9
  • 23
2
votes
2 answers

draw a shadow around the shape,core graphic

I am drawing a shape with a stroke around it by doing following - (void)drawRect:(CGRect)rect { // Draw a cross rectagle CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); …
tranvutuan
  • 6,089
  • 8
  • 47
  • 83
2
votes
2 answers

draw a stroke around the shape, core graphic

I am drawing a shape like following : - (void)drawRect:(CGRect)rect { // Draw a cross rectagle CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextMoveToPoint(context, 190, 0); …
tranvutuan
  • 6,089
  • 8
  • 47
  • 83
2
votes
1 answer

Allowing UITextField characters to render outside bounds

I have a problem with UITextField when I wish to render characters like Å and such within its rect. The top of it is being clipped out, Making the Å look like an A. In some cases i have solved it with a custom UITextField like this : -…
Nils Munch
  • 8,805
  • 11
  • 51
  • 103
2
votes
2 answers

how to call drawrect in UIView variable in a subclass of UIView?

I created a subclass of UIView, in this class i declare a UIView variable. I wanna call DrawRect of my UIView variable, because now when when i call DrawRect, it draws on my UIView class, not UIView variable, how can i do that? sorry for my bad…
Arash Zeinoddini
  • 801
  • 13
  • 19
2
votes
1 answer

Autolayout constraints do no work for NSView composition with drawRect:

I am trying to apply Autolayout constraints to a custom button which inherits from NSView. The button is rather complex and can be used as radio button for example. The user interface is composed in drawRect: as you can guess from the following code…
JJD
  • 50,076
  • 60
  • 203
  • 339
2
votes
1 answer

Empty drawRect implementation causes memory warning

I have a UIView on which I draw a UIBezierPath by finger. When I rezoom the view (say after a path is drawn) a redraw function is triggered, which rescales the BezierPath: - (void)redrawPathsWithScale:(float)scale { [_path…
Hasib Samad
  • 1,081
  • 1
  • 20
  • 39
2
votes
2 answers

UIBezierPath too many paths = too slow?

I have a loop in which I'm adding many (10000+) lines to a UIBezierPath. This seems to be fine, but once I try and render the bezierpath, my device becomes extremely slow and jerky. Is this because I've added too many lines to my path? Adding lines…
HHHH
  • 1,197
  • 2
  • 16
  • 28
2
votes
2 answers

How to add an alpha layer over part of UIImage in drawRect?

I am completely new to implementing custom drawRect method (and Core Graphics) but am doing so to improve the scrolling performance for my UITableView. Please do let me know if I am doing anything stupid. In my cell, I have a UIImage and over the…
minovsky
  • 857
  • 1
  • 15
  • 28
2
votes
1 answer

NSScrollView with sticky top, left and bottom 'headers'

I'm trying to create a timeline control in Cocoa. This is what I am trying to achieve. It's basically a standard timeline design. However, I don't know which approach to take. The problem lies with the top ruler, the left track list and the bottom…
Rengers
  • 14,911
  • 1
  • 36
  • 54
2
votes
2 answers

NSView with fill ( pattern image) scrolls when window changes size

I have an NSView with a drawRect - (void)drawRect:(CGRect)rect { // Drawing code NSPoint origin = [self visibleRect].origin; [[NSGraphicsContext currentContext] setPatternPhase:NSMakePoint(origin.x, origin.y)]; [[NSColor…
Andy Jacobs
  • 15,187
  • 13
  • 60
  • 91
2
votes
1 answer

drawInRect method works too slow

Now i have following: - (void)drawRect { // some drawing [bgImage drawinRect:self.bounds]; // some drawing } I have more than 40 views with text and some marks inside. I need to repaint all these views on user tapping - it should be…
k06a
  • 17,755
  • 10
  • 70
  • 110
2
votes
1 answer

Prevent UIImage from resizing when - drawInRect: is called

I'm rendering UIImage in the - drawRect: and placing it in the passed in CGRect by calling drawInRect: rect on the UIImage. It automatically resizes and stretches itself, which I don't want. How can I keep it the original size? UIImage* left =…
Chris
  • 7,270
  • 19
  • 66
  • 110