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

Why is drawRoundRectComplex() not documented in ActionScript?

In studying actionscript 3's graphics class, I've come across the undocumented drawRoundRectComplex() method. It's a variant of drawRoundRect() but with 8 parameters, the final four being the diameter of each corner (x, y, width, height, top left,…
Chunky Chunk
  • 16,553
  • 15
  • 84
  • 162
3
votes
1 answer

Rendering a UIWebView in drawRect with loadHTMLString

I am having a problem with UIWebView. I'd like to render my own html code in it. When I add a webview as a subview and put in some html code it renders just fine. When it gets down to some optimized drawing of tableview cell with the drawRect method…
Nick Weaver
  • 47,228
  • 12
  • 98
  • 108
3
votes
1 answer

In Swift, drawRect for custom view is not updating properly

Below is my drawRect function for a simple custom view. When I use var h: CGFloat = 200 the view displays itself properly: a rectangle part of which is black, part of which is red. But when I use var h: CGFloat =…
jxxcarlson
  • 223
  • 3
  • 13
3
votes
1 answer

UIView's drawRect not being called when swizzled

I am experimenting with advanced Objective-C methods. What I want to achieve is to append specific drawing code to an existing UIView. I started easily, I went on to declare my own drawRect method in a category: @interface UIView (Swizzled) -…
Legoless
  • 10,942
  • 7
  • 48
  • 68
3
votes
4 answers

UIView drawRect issue

I want to make custom UIView with border. Here is my code: - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 4.0); CGContextSetStrokeColorWithColor(context, [[UIColor…
Maria
  • 755
  • 1
  • 11
  • 29
3
votes
4 answers

Draw editable angles using drawRect?

I'm trying to create an application which draws angles every 3 taps by the user. Each tap creates the angle points and connects them. This is quite simple to do. However, now i'm trying to make these angles editable and it gets substantially harder.…
Josue Espinosa
  • 5,009
  • 16
  • 47
  • 81
3
votes
5 answers

Finding an angle with 3 CGPoints

In my application, a user taps 3 times and an angle will be created by the 3 points that were tapped. It draws the angle perfectly. I am trying to calculate the angle at the second tap, but I think I am doing it wrong (probably a math error). I…
Josue Espinosa
  • 5,009
  • 16
  • 47
  • 81
3
votes
1 answer

How do I draw a NSImage onto a NSView?

I'm pretty new to drawing images in general with Objective C. I have done image drawing in iPhone development, but now I want to do so on a Mac. In short, what is the Mac equivalent of the iPhone code below? - (void) drawRect: (CGRect) rect { …
Scsm326
  • 70
  • 1
  • 7
3
votes
1 answer

How to set the CAlayer bounds from my view controller for multiple subview

I am new to iOS programming. Please help me to sort out the following issue I have one set of view controller(.h, .m and .XIB) I have one set of view(.h&.m) 3.The view class is responsible for drawing gauge using -->drawRect -->CALayer and…
Brijesh Singh
  • 739
  • 1
  • 6
  • 23
3
votes
1 answer

ios method CTFrameGetLines return empty array

I have NSAttributedString like (only one symbol - s and attributes): s{ CTForegroundColor = " [ (kCGColorSpaceDeviceGray)] ( 0 0 )"; CTRunDelegate = ""; NSFont =…
frankWhite
  • 1,523
  • 15
  • 21
3
votes
1 answer

Draw lines that end in a brush shape?

Referring to the following image: . . . . notice how it does not end in a proper point. I use the following drawing code: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context,…
Jasper Blues
  • 28,258
  • 22
  • 102
  • 185
3
votes
1 answer

iOS - CGContextStrokePath/CGContextDrawPath remove black background color

I'm trying to draw a straight dashed line. I've gotten it so it draws the dashes, but this black background color remains. I've seem many answers to other questions, but none of them worked. Apple's documentation seems to point to the fill color and…
DrDisc
  • 281
  • 4
  • 12
3
votes
2 answers

Custom UIView in UIScrollView drawRect never called

I have in a controller: - (void)viewDidLoad { [super viewDidLoad]; // Add a scroolView self.scroolViewDay.scrollEnabled = YES; // Compute the content Size of the TableDays self.scroolViewDay.contentSize =…
gdm
  • 7,647
  • 3
  • 41
  • 71
3
votes
2 answers

drawRect() draw a custom shape, why can't fill color?

I 'm writing a custom shaped HUD and filling it with some color, but I can't fill the right part of my HUD. #define startX 20 #define startY 20 #define circleDiameter 60 #define PI 3.14159265358979323846 Here is the code: -…
HamasN
  • 524
  • 1
  • 5
  • 20
3
votes
2 answers

CAEmitterLayer not Shown

I'm simply adding a UIView to my storyboard view controller and then creating a UIView class to display a particle effect. I change the UIView's class name to that of the custom class I created. The code I'm using in the UIView class does not…
Jack120
  • 213
  • 1
  • 6
  • 21