UIBezierpath で丸みを帯びた四角形を作成しました。これは私にとって非常にうまく機能します。四角形の丸みを帯びたエッジが一種のエイリアシング効果を持つという問題が 1 つだけあります。ここに写真があります
次のように丸みを帯びた四角形を作成します。
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);