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

Undesirable black border on my rect when i draw it with QPainter.drawRect()

I have an undesirable black line of one or two pixels on the top of my rect when i use drawRect(). So my rect doesn't fill my widget completely. My code : QPainter Painter(this); QString TmpColor; int R, G, B, A; TmpColor = c_LabColor; R =…
2
votes
1 answer

setNeedsDisplay revisited

I have the often discussed drawRect not getting called. I've been through many posts, but have not resolved my issue. The solution is often described as calling -setNeedsDisplay. The answer to question setNeedsDisplay doesn't call drawRect …
Refactor
  • 524
  • 1
  • 11
  • 20
2
votes
1 answer

Why is awakeFromNib not called when the view is visited again?

I would like to know if there is a method equivalent to awakeFromNib. My app has 2 views and the 2nd view has a subclass (UIView) which I use to draw. I use a timer which is called from awakeFromNib in order to animate the drawing. - (void)…
R3D3vil
  • 681
  • 1
  • 9
  • 22
2
votes
1 answer

How to draw over a subview of NSView

I'm trying to draw at the top of my NSView which has some subviews. In fact I'm trying to reproduce the connection line style of Interface Builder. Here is the code I'm using for the moment: - (void)drawRect:(CGRect)dirtyRect { // Background…
klefevre
  • 8,595
  • 7
  • 42
  • 71
2
votes
0 answers

Offloading expensive drawing to background - can I prevent drawRect from clearing the NSView's dirtyRect?

I have a custom NSView 'MyView' that displays an NSImage that is expensive to create. Ideally, this rendering should happen on a background threat and MyView should update itself when rendering is done. To achieve this, I followed the suggestion in…
Sebastian
  • 904
  • 1
  • 8
  • 16
2
votes
1 answer

Draw Custom Shape Swift

I'm trying to draw a shape which would resemble a ticket - something like the image below. I'm just really interested in the outline and none of the inner details. I know this can be done by creating a custom UIView and overriding the drawRect…
Alk
  • 5,215
  • 8
  • 47
  • 116
2
votes
1 answer

How to improve the performance of [NSString drawInRect:withFont]?

I'm implementing an app for a micro blog service, something similar to twitter. I've done everything I know to improve the performance, including using drawRect instead of sub view based architecture. After run the app with Instrument, I found that…
Allen Hsu
  • 3,515
  • 3
  • 25
  • 38
2
votes
2 answers

Multiple custom backgrounds for UIToolbar

In order to create an absolute bottomed footer on top of a tableView I found that using UIToolbar for this and adding custom views for it worked fine. My problem is that I already use this as a toolbar for a webview, and here with another…
doh
  • 387
  • 1
  • 4
  • 15
2
votes
1 answer

iOS UIImage.drawInRect (CGContextDrawImage) performance

I have an app that lets the user manipulate items like text, images, shapes (vector images). They are stacked on top of each other like layers are in Photoshop. To manipulate means to translate, resize, rotate. I use drawInRect to draw all my items.…
Ilea Cristian
  • 5,741
  • 1
  • 23
  • 37
2
votes
1 answer

Why does TCanvas.Rectangle() with pmXOR pen only work "sometimes"?

I developed the following AnimateRects() method to draw an animation rectangle on the Windows desktop. I use it for animating display of a modal form, making it appear to have "grown" from a grid cell. I call the method once with the bExpand…
Mark Wilsdorf
  • 751
  • 1
  • 5
  • 18
2
votes
1 answer

ios Setting the RoundCorner does not work after override drawRect,but normal UIView is ok

I wrote an example about Wave Animation.The animation is ok,but I don't understand why the custom UIView needs to add "self.layer.masksToBounds = YES" to have the round Corner. This is a custom UIView. I have rewritten its drawRect. If i don't set…
2
votes
2 answers

Read/Unread cell (using drawrect)

My app downloading posts from internet to UITableViewCell. When user taps on cell, i am need to set this article as read (like on Mail.app). I dont know how to do that. I am adding url (when user press cell) to database (like "url|url|url"), open…
2
votes
1 answer

Overriding drawRect(_:) in UITableViewHeaderFooterView results in black background

1. Empty custom view implementation I created an empty subclass of UITableViewHeaderFooterView as follows: class MyCustomHeaderView: UITableViewHeaderFooterView { } I registered that class with my table…
Mischa
  • 15,816
  • 8
  • 59
  • 117
2
votes
0 answers

draw(_ rect: CGRect) content blurry when applying CGAffineTransform scale

I have a custom UIView that draws a check mark like so: (made in paintcode) import UIKit class AnimationCheckMarkView: UIView { override func draw(_ rect: CGRect) { //// General Declarations let context =…
KexAri
  • 3,867
  • 6
  • 40
  • 80
2
votes
2 answers

Draw simple Text in a MKPolygonView

Hello I try to draw text in a MKPolygonView. I made a subclass of MKPolygonView and added it to my MKMapView. The Polygon shows up correctly, but I can't see the Text. Can anyone help me? -(void)drawMapRect:(MKMapRect)mapRect…
user505877
  • 51
  • 3