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

UIView's drawRect Calls When Backgrounded

I am working a multitasking app which continues for a while after being sent to the background. I noticed that the drawRect methods in one of the UIView gets called constantly when the app is in the background. This drawRect method is responsible…
XCool
  • 976
  • 11
  • 32
0
votes
1 answer

Link recognition in custom UITableview cells

I have an app where i use custom table cells.The problem is that i want to have url,email,phone number and fabebook link recognition on them.I tried it by adding uitextviews as subviews to cell which naturally caused some performance problems.What…
Ilker Baltaci
  • 11,644
  • 6
  • 63
  • 79
0
votes
2 answers

iOS: CGContextRef drawRect does not agree with input

Background : I would like to draw blocks when the user touch up somewhere. If the block is there, I want to erase it. I manage the blocks by using NSMutableArrayto keep track of points where the block should go. Every time user touches, it will…
Byte
  • 2,920
  • 3
  • 33
  • 55
0
votes
1 answer

drawRect:/renderInContext: issues

Seem to be having a bit of an issue trying to draw my view into a context. My basic setup is, I have a view controller that owns a UIPageViewController in which I load controllers with views that can be drawn on by the users finger. Basically I have…
George Green
  • 4,807
  • 5
  • 31
  • 45
0
votes
2 answers

CoreGraphics drawRect in a cocos2d project EXEC BAD ACCESS

I got a interesting riddle here. My cocos2d project uses a UIView to display nicer popups than the regular alert view. To be more flexible in the size of the popup, I draw the background in the drawRect method. But first the hierarchy how I…
zeiteisen
  • 7,078
  • 5
  • 50
  • 68
0
votes
2 answers

Calling setNeedsDisplay on a UIView from another class

I have a UIView subclass that I manipulate a lot of graphics on based on touches. All the [self setNeedsDisplay] calls seem to be fine. However, I used an instance variable pointer to my same UIView subclass instance, and then tried manipulating…
Craig
  • 16,291
  • 12
  • 43
  • 39
0
votes
1 answer

Position UILabel in circle

I want to position a UILabel in the center of my Circle but I can't seem to affect the position of the label. I can only seem to affect the position of the label by changing the height of CGRect frame. changing the other values doesn't affect the…
Ramin Afshar
  • 989
  • 2
  • 18
  • 34
-1
votes
2 answers

UIView drawRect is jerky

UIView drawRect is jerky i.e., does not scroll smoothly across the screen. I have tried performing 'setNeedsDisplay' at various intervals from 200-ms to 500-ms and nothing seems to improve the look. That is as the plots move across the screen they…
-1
votes
1 answer

NSView Drawing & IsFlipped with overlayed image

I've drawn onto an NSView which displays fine except for the fact it was flipped. I've set isFlipped to YES so it displays the correct way round. I then overlay an image using drawInRect and [super drawRect:dirtyRect]; The problem is the overlayed…
-1
votes
1 answer

Draw image (as an overlay) on top of drawRect NSView (macOS & ObjC)

I have a drawing that I'm happy with on a drawRect, I'm now trying to overlay an image from a specific path, I'd like it to go on top of the current drawing as an overlay. Does anyone know what the best way to do this is, I'd like to be able to set…
-1
votes
1 answer

How to give a variable a certain value after draw() is called?

I'm trying to declare a constant that should have a value that is calculated using the frame property of UIView. Of course, I cannot access this property when declaring the constant outside of draw(), and I'm trying to find a workaround. I've read…
Xcoder
  • 1,433
  • 3
  • 17
  • 37
-1
votes
1 answer

Swift - function inside function?

Following the wonderful post about IBInspectable / IBDesignable, I am reading the example code and can't understand how function drawRect contains another functions. Can somebody explain? override func drawRect(rect: CGRect) { .... func…
Luda
  • 7,282
  • 12
  • 79
  • 139
-1
votes
1 answer

What unit does Swift use for angles?

Am am writing some code to draw circular charts, and while reading some example code, became confused about how angles are measured in Swift. In the first post I read, Swift seems to use radians: CGContextAddArc(context, origo.x, origo.y, radius,…
user31415
  • 446
  • 7
  • 16
-1
votes
1 answer

How to implement auto layout using core graphics in swift

i have a little problem. As you can see i have created a triangle (which is "context") and the triangle's angle (which is "retVinkel") using Core graphics. Now, when i run the app on Iphone 6s it looks just fine, right in the middle where i want it…
A. stein
  • 87
  • 1
  • 1
  • 7
-1
votes
1 answer

iOS drawRect draw a border

Hi I have draw a gradient in core graphic using drawRect function.. but I don't know how to draw a border to surround this view? this is my code, could anyone help? - (void)drawRect:(CGRect)rect { CGColorSpaceRef colorSpace =…
Neo
  • 167
  • 1
  • 1
  • 12