drawrect

Custom UITableViewCell and animation on setSelected:animated:

南楼画角 提交于 2019-12-03 21:03:06
I have a UITableViewCell subclass that does its drawing in a drawRect: method. The whole rectangle is custom drawn, including the background. I was able to get very complex cells while keeping the scrolling very smooth. My problem: I call [table deselectRowAtIndexPath:path animated:YES]; whenever the view appears, in order to comply with Apple's HIG. However, no animation occurs. It worked when I had a custom view (created with subviews) that was transparent (so Apple's background would appear below), of course. Now it doesn't. My drawRect: is called once during the "animation time", about

UITableViewCell drawInRect iOS7

折月煮酒 提交于 2019-12-03 16:25:47
Hi I am trying to draw strings in my UITableViewCell in iOS 7 with the following code -(void)drawRect:(CGRect)rect{ [super drawRect:rect]; CGRect playerNameRect = CGRectMake(0, kCellY, kPlayerNameSpace, kCellHeight); NSDictionary*dictonary = [NSDictionary dictionaryWithObjectsAndKeys: [UIColor hmDarkGreyColor], NSForegroundColorAttributeName, kFont, NSFontAttributeName, nil]; [self.playerName drawInRect:playerNameRect withAttributes:dictonary]; } However I can not get anything to appear... self.playerName is not nil, and the playerNameRect is correct. I was previously using the following code

Drawrect with CGBitmapContext is too slow

你说的曾经没有我的故事 提交于 2019-12-03 15:03:49
问题 So I've got a basic drawing app in the process that allows me to draw lines. I draw to an off screen bitmap then present the image in drawRect . It works but its way too slow, updating about half a second after you've drawn it with your finger. I took the code and adapted it from this tutorial, http://www.youtube.com/watch?v=UfWeMIL-Nu8&feature=relmfu , as you can see in the comments people are also saying its too slow but the guy hasn't responded. So how can I speed it up? or is there a

On iOS, setNeedsDisplay really doesn't cause drawRect to be called… unless CALayer's display or drawInContext finally calls drawRect?

六眼飞鱼酱① 提交于 2019-12-03 08:51:47
I don't really understand how CALayer's display and drawInContext relate to drawRect in the view. If I have an NSTimer that sets the [self.view setNeedsDisplay] every 1 second, then drawRect is called every 1 second, as shown by an NSLog statement inside of drawRect . But if I subclass a CALayer and use that for the view, if I make the display method empty, then now drawRect is never called. Update: But display is called every 1 second, as shown by an NSLog statement. If I remove that empty display method and add an empty drawInContext method, again, drawRect is never called. Update: But

UIBezierPath draw circle with different strokes

左心房为你撑大大i 提交于 2019-12-03 07:30:42
问题 Basically I need to have a circle with stroke in different color, all equal in size. For example, 1/2 is blue and 1/2 is red. Image (sorry for so bad image): How can I draw something like this? 回答1: There are lots of ways to do it, but one is to just draw two bezier paths, one for each side: - (void)drawRect:(CGRect)rect { UIBezierPath *blueHalf = [UIBezierPath bezierPath]; [blueHalf addArcWithCenter:CGPointMake(100, 100) radius:90.0 startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES];

Drawing animation

走远了吗. 提交于 2019-12-03 05:20:07
问题 I'm creating a simple app where when the user presses a button, a series of lines will be drawn on the screen and the user will be able to see these lines drawn in real time (almost like an animation). My code looks something like this (has been simplified): UIGraphicsBeginImageContext(CGSizeMake(300,300)); CGContextRef context = UIGraphicsGetCurrentContext(); for (int i = 0; i < 100; i++ ) { CGContextMoveToPoint(context, i, i); CGContextAddLineToPoint(context, i+20, i+20);

Drawrect with CGBitmapContext is too slow

安稳与你 提交于 2019-12-03 03:49:48
So I've got a basic drawing app in the process that allows me to draw lines. I draw to an off screen bitmap then present the image in drawRect . It works but its way too slow, updating about half a second after you've drawn it with your finger. I took the code and adapted it from this tutorial, http://www.youtube.com/watch?v=UfWeMIL-Nu8&feature=relmfu , as you can see in the comments people are also saying its too slow but the guy hasn't responded. So how can I speed it up? or is there a better way to do it? any pointers will be appreciated. Heres the code in my DrawView.m . -(id)initWithCoder

Why an empty implementation of drawRect: will adversely affect performance during animation

倖福魔咒の 提交于 2019-12-03 03:09:37
I am subclassing my UIView class. The Xcode (I am using 4.6.3) auto generated code says, /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ It raised few questions in my mind : 1) Why an empty implementation of drawRect: will cause adverse performance during animation. 2) When should I implement drawRect: . 3) If I am implementing drawRect: then what should be taken as precaution for the best practice. To know when to use -drawRect: and when to do things

CALayer vs CGContext, which is a better design approach?

倾然丶 夕夏残阳落幕 提交于 2019-12-02 23:29:52
I have been doing some experimenting with iOS drawing. To do a practical exercise I wrote a BarChart component. The following is the class diagram (well, I wasnt allowed to upload images) so let me write it in words. I have a NGBarChartView which inherits from UIView has 2 protocols NGBarChartViewDataSource and NGBarChartViewDelegate. And the code is at https://github.com/mraghuram/NELGPieChart/blob/master/NELGPieChart/NGBarChartView.m To draw the barChart, I have created each barChart as a different CAShapeLayer. The reason I did this is two fold, first I could just create a UIBezierPath and

UIBezierPath draw circle with different strokes

柔情痞子 提交于 2019-12-02 21:00:27
Basically I need to have a circle with stroke in different color, all equal in size. For example, 1/2 is blue and 1/2 is red. Image (sorry for so bad image): How can I draw something like this? There are lots of ways to do it, but one is to just draw two bezier paths, one for each side: - (void)drawRect:(CGRect)rect { UIBezierPath *blueHalf = [UIBezierPath bezierPath]; [blueHalf addArcWithCenter:CGPointMake(100, 100) radius:90.0 startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES]; [blueHalf setLineWidth:4.0]; [[UIColor blueColor] setStroke]; [blueHalf stroke]; UIBezierPath *redHalf =