drawrect

iOS 5 UIView drawRect override not working on device

北城余情 提交于 2019-12-07 03:52:18
问题 I'm preparing my iPhone app to publish on iOS 5 GM and came across a bug with UIView. When I override the drawRect method on a subclass, the Simulator shows the desired result but when I try to test on an actual device, the drawRect override doesn't have any effect at all. I even placed a logging statement inside a drawRect override and confirmed that it is being called. Has anyone else noticed this problem? Here's a override code I'm using: - (void)drawRect:(CGRect)rect { DebugLog( @"***

CADisplayLink and drawRect

我是研究僧i 提交于 2019-12-07 03:23:46
问题 I need help to better understand how CADisplayLink and drawRect behave, so that I can figure out how to keep my app's framerate at a smooth 60fps. My (presumably incorrect) understanding so far is the following: 1) CADisplayLink calls a specified selector when the display refreshes (a so-called "v-sync" event; about every 16ms). 2) iOS uses double buffering, meaning that while one frame buffer is being displayed we can prepare (draw to) the other, and the two are swapped at the next v-sync

setNeedsDisplay does not trigger drawRect in subviews as expected

余生颓废 提交于 2019-12-07 03:09:43
问题 I'm struggling with setNeedsDisplay . I thought it was supposed to trigger calls of drawRect: for the view for which it is called and the hierarchy below that if it's within the view's bounds, but I'm not finding that to be the case. Here is my setup: From the application delegate, I create a view whose size is a square that covers essentially the whole screen real estate. This view is called TrollCalendarView . There is not much that happens with TrollCalendarView except for a rotation

Clear UIView of drawing?

[亡魂溺海] 提交于 2019-12-07 00:23:09
问题 I am using a subclass of UIView to draw, this subclassed view is used to get your signature on a view controller. There is a clear button which is supposed to clear the UIView except it doesn't work. Here is what I have tried. subclass.h @implementation subclassed uiview { UIBezierPath *path; UIImage *incrementalImage; // (1) } - (id)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self setMultipleTouchEnabled:NO]; [self setBackgroundColor:[UIColor clearColor]

Manually color fading from one UIColor to another

♀尐吖头ヾ 提交于 2019-12-06 23:51:23
问题 I'm trying to fade one UIColor to another in a drawRect . I've created this function to calculate a color at a certain percentage: - (UIColor *)colorFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor percent:(float)percent { float dec = percent / 100.f; CGFloat fRed, fBlue, fGreen, fAlpha; CGFloat tRed, tBlue, tGreen, tAlpha; CGFloat red, green, blue, alpha; if(CGColorGetNumberOfComponents(fromColor.CGColor) == 2) { [fromColor getWhite:&fRed alpha:&fAlpha]; fGreen = fRed; fBlue = fRed;

How to erase lines in a subview

别来无恙 提交于 2019-12-06 13:35:53
问题 I'm working on an photo app where you can draw lines on an photo. The background is the photo, and via drawrect I draw lines on a subview. Every thing works but how can I erase lines on a subview (like an eraser), I tried with clearColor as setStroke. Is it possible to erase the lines like this. 回答1: An implementation of the response given by @omz could be: (assuming imgBlank is a UIImageView placed on top of the main view of the viewcontroller) -(void)touchesMoved:(NSSet *)touches withEvent:

Why is drawRect leaving parts of image?

你说的曾经没有我的故事 提交于 2019-12-06 08:17:30
Here's my case: I have a table which contains a list of restaurants, each entry shows the results of inspections over time on a scorebar that is drawn using drawRect. When the user scrolls the table down and then up, so that scorebars with yellow and red squares are shown, previous scorebars pick up those squares. Dates are also drawn into previous scorebars. My problem lies in getting rid if the old squares. Shouldn't they be erased each time drawRect is called? I've placed three images below that hopefully explain what I mean. I don't think this is a problem with table rows caching custom

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

百般思念 提交于 2019-12-06 07:08:27
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 advance. -Doug UPDATE 8 Dec 8:28am EST Here is the relevant code with explanatory wordage. I am running

Resize line from endpoints

人走茶凉 提交于 2019-12-06 05:51:34
I am drawing annotations on a view. The line annotation is causing a problem; I have a parent class of Shape (extended from UIView). All the annotations are subclass of shape. In each annotation class i have override the drawRect method. DrawingCanvas class (extended from UIView and is a subview of my viewController's parent view) handles the pan gesture. Here is a piece of code -(void) panGestureRecognizer: (UIPanGestureRecognizer *) panGesture { static CGPoint initialPoint; CGPoint translation = [panGesture translationInView:panGesture.view]; static Shape *shape; if(panGesture.state ==

UIView with CATransform3D inside a UITableViewCell = Choppy Scrolling

▼魔方 西西 提交于 2019-12-06 05:42:17
问题 I'm using a custom UITableViewCell , into which I am placing a subclassed UIView (within contentView , natch). The UIView in question displays a directional arrow and two lines of supporting text. The arrow is displayed by means of a layer with a background color and an arrow-shaped mask. The background color changes to one of two possibilities depending on the direction the arrow is pointing. The view receives a NSNotification whenever it needs to update the arrow (based on, but not