2011-10-28 130 views
2

我在iOS上繪製了一條線條,將一條路徑拖動到CALayer上。我如何用逐漸增大的lineWidth(筆畫寬度)來描邊這條線,以便線的左端比右端更薄? (它必須是一條線,而不是形狀或閉合路徑,因爲我將使用strokeEnd屬性。)在iPhone上使用增加的線寬繪製線條

感謝您的幫助!

回答

0

使用繪圖功能。起初習慣起來很麻煩,但它的工作。如果您需要更多的幫助,請隨時發表評論

-(void)draw{ 
    float lineHeight = 5;//change this as you see fit, like set it equal to an incrementing/decrementing variable of your choice... 
    glEnable(GL_LINE_SMOOTH); 
    glLineWidth(lineHeight); // change this as you see fit 
    glColor4ub(255,255,255,255); // change these as you see fit :) 
    ccDrawLine(ccp(10,310), ccp(30,310)); // these numbers are probably off, you'll have to mess with these to get it in the right position :) 
     [super draw]; 
     } 
+0

我正確地認爲這與cocos2D有關嗎?我正在使用QuartzCore CALayer/CAShapeLayer,而不是CCLayer .. – hsdev

+0

哦,廢話抱歉,您可能需要cocos2d ...對不起,我認爲它是xcode的一部分。 – Gabe

+0

除了使用cocos2D之外,還有其他可行的解決方案嗎? – hsdev