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
1 answer

For loop in drawRect

I need to draw a graph in a view controller. I've created a scrollview and a view as subviews of my self.view with auto layout. My data comes from an array (Core Data) that contains thousands of NSNumber. Right now, this is the code I…
Imanou Petit
  • 89,880
  • 29
  • 256
  • 218
2
votes
1 answer

UICollectionViewCell drawRect: issues

I need to draw a circle in some UICollectionViewCell. Circle with different colored border and background color. My code. UICollectionViewController - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView…
Alexey
  • 397
  • 1
  • 4
  • 12
2
votes
1 answer

How to apply UIScrollView's transform to UIView?

In my app I have a scrollview with an added subview called allView. In the scrollview delegate methods I am applying value of the current transformation of the scrollview's subview to another view called paint view paintView.transform =…
Janusz Chudzynski
  • 2,700
  • 3
  • 33
  • 46
2
votes
1 answer

Can I get a CGColor from CGGradient?

I need to get a CGColor from a CGGradientRef, and use the color as a stroke colour in a drawing app for iOS 7. Is that possible?
maharet313
  • 23
  • 3
2
votes
0 answers

UIVIewController and UIView - How to refresh UIView

After having spent the whole day looking for a solution I feel only more confused and upset. Let's face the problem: I'm developing a single view iOS app made up of an AppDelegate (of course..), A ViewController and a "DrawingClass" (subclass of…
Alberto
  • 4,212
  • 5
  • 22
  • 36
2
votes
2 answers

Android: DrawRect Not getting Displayed on Canvas of HD phones

Lately I have developed the Board Game ( https://play.google.com/store/apps/details?id=com.pradhan.manoj.CoinStack ). It is working fine in all Android powered devices except few phones those are having HD display including Micromax Canvas HD and…
mkp77
  • 21
  • 4
2
votes
1 answer

Drawing equally spaced rectangles inside a rectangle

I am trying to make a custom view for Android. I need a big ractangle that holds 7 other rectangles (equally spaced and padded from inside the main rectangle, representing days of week). With my current code, I get the following result: But what I…
Dumbo
  • 13,555
  • 54
  • 184
  • 288
2
votes
0 answers

Android: Drawing on surfaceview in listview

I have a listview with a few TextViews and a SurfaceView. Most items in the listview are dynamic and depend on data from an external server. I'm using a custom ArrayAdapter to keep track of things. What I want to do is to draw rectangles on the…
2
votes
2 answers

iPhone: drawRect called once

I'm calling setNeedsDisplayInRect from an NSTimer function every two seconds. This works perfectly, and draws a square in a random position, with a random color. However, in some circumstances I would like to draw a square x number of times in the…
Carl
  • 209
  • 1
  • 3
  • 13
2
votes
1 answer

Custom drawRect: parameter

Is there any way to add a second parameter in a custom UIView class in the drawRect method? I am currently using a UIView to draw a text string but the text itself is set in the drawRect method. Is there any way to pass in the text variable in…
Steven Ritchie
  • 228
  • 1
  • 2
  • 12
2
votes
1 answer

How do I trim the text and add Ellipsis (...) while using drawInRect: on iOS 7?

I've create a subview and implementing the drawRect: method for custom drawing. How do I achieve a behavior similar to that of a UILabel which automatically adds the Ellipsis (...) if the text is too long to fit in its frame. Here is the code -…
vivek241
  • 666
  • 1
  • 7
  • 18
2
votes
1 answer

Android: drawRect without antialiasing

I draw a rectangle on a bitmap and its borders are antialiased or have some effects as you can see: original image: How to switch off that effect to get solid lines like this: I use this code: Bitmap mBuffer = Bitmap.createBitmap(width, height,…
Zsolt
  • 365
  • 3
  • 12
2
votes
5 answers

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…
dugla
  • 12,774
  • 26
  • 88
  • 136
2
votes
1 answer

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…
John R Doner
  • 2,242
  • 8
  • 30
  • 36
2
votes
1 answer

Resize line from endpoints

I am drawing annotations on a view. The line annotation is causing a problem; I have a parent class of Shape (extended from UIView). All the annotations are subclass of shape. In each annotation class i have override the drawRect method.…
Nabeel Thobani
  • 939
  • 10
  • 23