0
我使用UIBezierpath創建了一個圓角矩形,這對我非常有用。只有一個問題,矩形的圓邊具有一種混疊效果。 這裏是一個圖片使用RoundedRect對UIBezierpath進行抗鋸齒
我創建了圓角的矩形這樣的:
CGFloat radius = 12;
CGRect frame1 = CGRectMake(self.bounds.origin.x, self.bounds.origin.y+(self.bounds.size.height/heightFactor), self.bounds.size.width-shadowConst, self.bounds.size.height-(self.bounds.size.height/heightFactor)-shadowConst);
CGRect frame2 = CGRectMake(self.bounds.size.width-(self.bounds.size.width/widthFactor), self.bounds.origin.y+(self.bounds.size.height/(heightFactor*2)), (self.bounds.size.width/widthFactor)-shadowConst, (self.bounds.size.height/heightFactor));
UIBezierPath *result =
[UIBezierPath bezierPathWithRoundedRect: frame1 cornerRadius:radius];
[result appendPath:
[UIBezierPath bezierPathWithRoundedRect: frame2 cornerRadius:radius]];
[result fill];
[result addClip];
CGContextDrawLinearGradient(context, gradient2, CGPointMake(0, 0), CGPointMake(0, self.bounds.size.height), 0);
我也試圖在沒有顏色的情況下繪製它。同樣的鋸齒正在發生... 我不太明白你對常數的含義。 ShadowConst只是一個整數,其值爲3,heightFactor也是一個整數常量。這怎麼會導致別名? 編輯:我的猜測是它是繪圖機制內部的東西。 – arnoapp 2012-07-28 17:21:32
抱歉,直到現在纔看到您的評論。但看到你接受了它,所以我認爲你基於我的提示找出了它:) – runmad 2012-08-08 22:27:15