views:

38

answers:

0

Hi, plz look at the code first

                UIGraphicsBeginImageContext(self.view.frame.size);
         contextRef=UIGraphicsGetCurrentContext();
  CGContextSetLineCap(contextRef, kCGLineCapRound);
  CGContextSetLineWidth(contextRef, brushWidth);
  CGContextSetRGBStrokeColor(contextRef, 1.0, 1.0, 1.0, 1.0);



  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
  CGColorRef glowColor = CGColorCreate( colorSpace, colorValues );
  CGContextSetShadowWithColor( contextRef,CGSizeMake( 0.0, 0.0 ), 100.0f, glowColor );
  //CGContextSetShadow(contextRef, CGSizeMake(0.0, 0.0),100.0f);
  CGContextBeginPath(contextRef);

  while (beginY<ensdY) {
   //brushWidth=brushWidth-.05;

   CGContextMoveToPoint(contextRef, beginX, beginY);
   CGContextAddLineToPoint(contextRef,nextX,nextY);


   beginX=nextX;beginY=nextY;
   nextY=nextY+10;
   if (arc4random()%3==0) {
    nextX=nextX+arc4random()%10;
   }


   else {
    nextX=nextX-arc4random()%10;

   }

  }

  CGContextStrokePath(contextRef);
  drawImage.image  = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();

I call this after a certain time in regular basis.... everything is ok in simulator...but when i installed in iPhone it becomes slow.i find that this is for CGContextSetShadowWithColor but don't know why....can anyone help???