2012-05-17 4 views
3

나는 분필처럼 선을 그려보고 싶다. 그리고 선의 가장자리가 희미합니다. 칠판에 분필 그리기를 사용하는 것과 같습니다.분필처럼 선을 그 으려면 어떻게해야합니까?

어떻게받을 수 있습니까? 이제 이미지를 사용하여 선을 그렸습니다. 그러나 선이 희미하지 않기 때문에 칠판에 그리는 것처럼 보이지 않습니다. 제발, 나에게 몇 가지 제안을 해줘. 얼룩말 행이있는 패턴 이미지를 사용하는

for (NSDictionary *dictStroke in self.arrayStrokes) 
    { 
     NSArray *arrayPointsInstroke = [dictStroke objectForKey:@"points"]; 
     //UIColor *color = [dictStroke objectForKey:@"color"]; 

    UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"point.png"]]; 

     float size = [[dictStroke objectForKey:@"size"] floatValue]; 
     [color setStroke];  // equivalent to both setFill and setStroke 

     // draw the stroke, line by line, with rounded joints 
     UIBezierPath* pathLines = [UIBezierPath bezierPath]; 
     CGPoint pointStart = CGPointFromString([arrayPointsInstroke objectAtIndex:0]); 
     [pathLines moveToPoint:pointStart]; 
     for (int i = 0; i < (arrayPointsInstroke.count - 1); i++) 
     { 
      CGPoint pointNext = CGPointFromString([arrayPointsInstroke objectAtIndex:i+1]); 
      [pathLines addLineToPoint:pointNext]; 
     } 
     pathLines.lineWidth = size; 
     pathLines.lineJoinStyle = kCGLineJoinRound; 
     pathLines.lineCapStyle = kCGLineCapRound; 
     [pathLines stroke]; 

     arraynum++; 
    } 

답변

6

시도 :

여기 내 코드입니다. 그것은 분필 쓰기와 같은 효과를 줄 것입니다.

brushPattern = [[UIColor alloc]initWithPatternImage: [UIImage imageNamed:@"pattern.jpg"]]; 

- (void)drawRect:(CGRect)rect 
{ 
    [brushPattern setStroke]; 
    [myPath strokeWithBlendMode:kCGBlendModeNormal alpha:1.0]; // myPath - points to be drawn  
} 
관련 문제