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

draw line/point on existing UIView without drawRect?

I created line chart. Now I need to display point on this chart when I tap the screen. What would be the best method? Do I need to call drawRect method again, draw whole chart with marked point? I'm thinking about something like transparent layer…
plusz
  • 224
  • 2
  • 16
2
votes
2 answers

Adding outline shadow to a UIView which is iOS 3.0 compatible

I have two UIViewControllers A and B and they are added as subviews in the AppDelegate with B on top of A. When a UIButton on B is tapped B slides off to the left with the following code: [UIView beginAnimations:nil context:nil]; [UIView…
mbogh
  • 1,361
  • 11
  • 28
2
votes
0 answers

Animating (fading) CGContext properties within drawRect

I have a subclass of UIView that overrides drawRect. Within it, I'm using CGBlendModes to give a coin graphic a visual effect. Works like a charm (no pun intended ha ha). I would like to animate the CGContextSetFillColor alpha property within…
Joe
  • 3,772
  • 3
  • 33
  • 64
2
votes
1 answer

Drawing from PaintCode StyleKit to UITabBarItem

I need to use a PaintCode StyleKit in a UITabBarItem. If I was working with a UIButton, I would simply use these lines of code: override func drawRect(rect: CGRect) { MyStyleKit.drawButton(self.frame) } But if I have to work with a UITabBarItem…
Fabio Cenni
  • 841
  • 3
  • 16
  • 30
2
votes
1 answer

UIView CGGradient clipped to drawn "frame"

I'm trying to make a more sophisticated drawing of a UILabels (or a UIView, putting the UILabel on top, should that be required) background. Since I want this to resize automatically when the user changes iPhone orientation, I am trying to implement…
jollyCocoa
  • 691
  • 7
  • 20
2
votes
4 answers

UILabel won't center in UIView

I'm trying to create a custom UIView that can be used as a progress bar or similar (@IBDesignable with IBInspectables). I want a centered (primarily X-axis, but for now Y as well) UILabel in this view. private func addLabel() { let label =…
Mattias
  • 415
  • 3
  • 13
2
votes
2 answers

Draw transparent UIBezierPath line inside drawRect

I am trying to achieve a transparency path in the drawRect method. This is the simple code I have created: override func drawRect(rect: CGRect) { let clippingPath = UIBezierPath() UIColor.whiteColor().set(); …
Tomus85
  • 57
  • 1
  • 6
2
votes
3 answers

Text size is not same when draw text on UIimage

I am working on project where I need to add text to the image which is coming from the textfield. But when I see the text on the image it shows the font size smaller than the font size of textfield. I am using following method to draw text on…
Gopal Devra
  • 564
  • 2
  • 5
  • 24
2
votes
1 answer

UIScrollView redrawing content while scrolling?

I know there is a property or method that makes the scrollview/uiview call drawRect: method while is scrolling. By default is disabled because of performance reasons but I need to enable it. I cannot remember the name of the method hence I cannot…
nacho4d
  • 43,720
  • 45
  • 157
  • 240
2
votes
1 answer

UIBezierPath not updated as expected

This is my code for my custom view: class CircleView3: UIView { let endPoint = 270.0 var index = 0.0 var startPoint: Double { get{ index++ let div = 360.0/60.0 let vaule = div * index …
sarah
  • 1,201
  • 1
  • 9
  • 29
2
votes
1 answer

drawRect not called everytime

I am trapped in a strange problem, I am making a keyboard extension, in which I need to draw highlight of key on touch. I am successfully able to do that, however strangely for some keys to the left top corner specially the keys Q and A, don't draw…
iphonic
  • 12,615
  • 7
  • 60
  • 107
2
votes
1 answer

How to draw a "drag and drop" area in a custom NSView

I'm building my first application, in which I have a custom NSView which is used for dragging and dropping files. I've got the registration of the dragging operation down, but still need to design the drag and drop area, so the users actually know…
anders
  • 457
  • 2
  • 19
2
votes
1 answer

Single drawRect implementation across multiple UIView subclasses

Across my app I have several different subclasses of UIView: UIDatePicker, UIPicker, UIButton, UITableView, UITableViewCell, UITextView, etc. etc... For each of these I'd like to add a very simple drawRect custom implementation that I have working…
paulmrest
  • 414
  • 4
  • 14
2
votes
1 answer

Objective-C | NSBezierPath draw and color on action

I have a custom view class with a tracking area. I want that, when the mouse enters the tracking area, a bezier is drawn with a color, and when the mouse exits the area the bezier disappear. In order to make it disappear I read that the only way is…
2
votes
2 answers

If I call setneedsdisplay frequently, how often will the drawrect be called? why is that?

In my case, the drawRect: will not be called immediately after every single setNeedsDisplay is called. For example, I think the following code is same as my case. for (int i = 0; i < 100; ++i) { [self setNeedsDisplay]; }
Grey
  • 253
  • 4
  • 15