drawrect

iPhone how do i make two connected line to follow to the position?

被刻印的时光 ゝ 提交于 2019-12-11 06:36:19
问题 I made the tail of speech bubble using core graphic and The tail part of the speech buble supposed to move to any point as i want. The problem is when the tail's end part(the pointy part) is downward it works fine. But when the bubble is upside down, like the bubble part is on the bottom the tail part is on the top, the tail part's 2 connected line crosses each other and form a X, when it supposed to be like /\ can someonle please help me? double angle(CGPoint p1, CGPoint p2) { //BOOL bRev =

How to let drawRect get the value of points from ViewController and draw?

巧了我就是萌 提交于 2019-12-11 04:35:51
问题 I created a class newView from UIView and aim to draw a quadrangle. the 4 coners (ClipPointA, ClipPointB, ClipPointC, ClipPointD) of the quadrangle are supposed to read value from ViewController. newView.h: @interface newView : UIView { CGPoint ClipPointA, ClipPointB, ClipPointC, ClipPointD; } @end newView.m: @implementation newView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code. } return self; } - (void)drawRect:(CGRect)rect { //

Why isn't the “rectangle” that I want to draw on my Qt widget showing up?

瘦欲@ 提交于 2019-12-11 03:32:42
问题 I basically want to display a rectangle on a dialog window widget. Using another question as reference, I tried to adapt the framework of using a QLabel and painting to it (the process overall seems overly complicated). I started by making a member in the dialog box's class: QLabel* label; In the constructor of the dialog box: label = new QLabel(this); label->setGeometry(20, 50, 50, 100); Just to try and make it work, I gave the dialog box a button to make the "rectangle" created with the

Is drawRect -— leaking memory

廉价感情. 提交于 2019-12-11 02:54:35
问题 I am currenty seeing a problem with memory leaks, it seems to come from this code: - (void)drawRect:(CGRect)rect { CGImageRef cgImage = CGBitmapContextCreateImage(offScreenBuffer); UIImage *uiImage = [[UIImage alloc] initWithCGImage:cgImage]; CGImageRelease(cgImage); [uiImage drawInRect:self.bounds]; [uiImage release]; } this method is called from touches events ... -(void)drawPoint:(UITouch *)touch { currentLoc = [[PointLocation alloc] init]; currentLoc.location = [touch locationInView:self]

Draw simple Text in a MKPolygonView

試著忘記壹切 提交于 2019-12-11 01:46:03
问题 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 zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{ [super drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context]; CGRect overallCGRect = [self rectForMapRect:self.overlay.boundingMapRect]; UIFont* font = [UIFont

Draw transparent UIBezierPath line inside drawRect

霸气de小男生 提交于 2019-12-11 01:08:37
问题 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(); clippingPath.moveToPoint(CGPoint(x: 10, y: CGRectGetHeight(self.bounds) / 2)) clippingPath.addLineToPoint(CGPoint(x: CGRectGetWidth(self.bounds) - 10, y: CGRectGetHeight(self.bounds) / 2)) clippingPath.lineWidth = 6 clippingPath.lineCapStyle = .Round clippingPath.stroke() } And this is

drawRect: speed and CGContextDrawRadialGradient (super slow?)

北城以北 提交于 2019-12-10 21:14:32
问题 I'm having problems with my UIView subclass' drawRect: function. I use CGContextDrawRadialGradient() in it, and it. When the user drags my UIView it struggled to keep up if I include the gradient. Using Time Profiler I see that literally > 98% of my time is spent in my subclass' drawRect : method. First: would using a static image of a gradient be faster? Second: is there any way to speed this up? Can I cache the gradient somehow? it doesn't change much but paths around it and intersecting it

Calling setNeedsDisplay in layoutSubviews?

别等时光非礼了梦想. 提交于 2019-12-10 15:17:23
问题 Consider a view with a custom background that is drawn in drawRect: . If the view changes size, the background need to be redrawn. Is this a bad idea? - (void) layoutSubviews { [super layoutSubviews]; [self setNeedsDisplay]; } If it is, what would be a better alternative considering I can't control who changes the size of the view? 回答1: Dont do that, it's not necessary. Set the contentMode of the view to UIViewContentModeRedraw : UIViewContentModeRedraw Redisplays the view when the bounds

Drawing Straight Lines with Finger on iPhone

99封情书 提交于 2019-12-10 14:55:51
问题 Background: I am trying to create a really simple iPhone app that will allow the user to draw multiple straight lines on the screen with their finger. I'm using these two methods in my UIViewController to capture the coordinates of each line's endpoints. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event Question: I would like the line to show up as soon as touchesEnded has fired and then keep drawing more lines on

iPhone + UIView. Enormous memory consumption during drawRect. Any strategies for reducing this?

落花浮王杯 提交于 2019-12-10 10:55:34
问题 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 any way to tell CoreGraphics to allocate just enough memory to draw each element (each element is a small rectangular block much smaller then the device display) and release the memory when done, rather then my current naive approach? Thanks in