は、最も簡単でパフォーマンスの高いソリューションは、おそらくUIImageView
を使用して、そのレイヤーのマスクとしてCAShapeLayer
を適用することであろう。
例:
UIImage *image = ...;
CGFloat ringWidth = 20.0;
CGRect outerCircleRect = CGRectMake(0, 0, image.size.width, image.size.height);
CGRect innerCircleRect = CGRectInset(outerCircleRect, ringWidth, ringWidth);
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:outerCircleRect];
[path appendPath:[UIBezierPath bezierPathWithOvalInRect:innerCircleRect]];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.fillRule = kCAFillRuleEvenOdd;
shapeLayer.path = [path CGPath];
UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
imageView.layer.mask = shapeLayer;
[self.view addSubview:imageView];
あなたは、これが機能するためにはQuartzCoreフレームワークを含める必要があります。
内側の円の半径を変更すると、シェイプレイヤーに新しいパスを割り当てることができます。これはアニメ化することさえできます。
出典
2012-02-11 20:58:19
omz
FWIWは、円形円板が切り取られた円板の用語であり、「円環」である。 – Benjohn