2012-04-30 51 views
1

我目前正在繪製一個UIImage一個UIBezierPath內像這樣的外邊緣:製作UIBezierPath半透明

UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0); 
UIBezierPath *polygonPath = [UIBezierPath bezierPath]; 

CGPoint curPoint = [self originalPoint:[[drawArray objectAtIndex:0]CGPointValue]]; 

// set the starting point for the lines 
[polygonPath moveToPoint:curPoint]; 

// go through each point in drawArray and add it to polygonPath 
for(NSInteger i = 1; i < [drawArray count]; i++) { 
    curPoint = [self originalPoint:[[drawArray objectAtIndex:i]CGPointValue]]; 
    // scale point 
    curPoint = CGPointMake(curPoint.x, curPoint.y); 

    [polygonPath addLineToPoint:curPoint]; 
} 

[polygonPath closePath]; 

[polygonPath addClip]; 

[image drawAtPoint:CGPointZero]; 

它的偉大工程,但是我想有「邊緣平滑」,稍透明,對於圖像,因爲我在另一個圖像上繪製它...現在邊緣非常粗糙。

感謝您的幫助!

回答

0

正如您在圖像上繪製。所以我建議你使用下面的代碼...

其中YourImage是您繪製線的UIImage。

[[UIColor colorWithPatternImage:YourImage] set]; 

For More Visit this reference

希望,這將幫助你...