如何画四张四等分的圆圈?
How to draw four images in circle quarterly equal?
我需要在一个圆圈中绘制四组图像,每季度相等。
任何人都可以帮助我下面是屏幕
你只需要加一个view
,比如200*200
然后向此视图添加 4 imageviw
然后设置cornerRadius
self.testview.layer.cornerRadius = 100;
self.testview.layer.masksToBounds = YES;
我刚刚设置了背景颜色,看起来像这样
您可以按照以下步骤来实现。
根据附加图像在 .xib 中创建一个视图。我创建了一个视图 "imageViewHolder"。其中有四个 UIImageView。因为我有四个图像都是白色背景,所以我使用了 2 个黑色标签并将它们用作行分隔符位图像。你可以根据你的要求使用任何颜色。
将 IBoutlet 设置为 ImageViewHolder
根据您的要求编辑以下代码
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// first make imageViewHolder round
[self getRoundCollage];
}
-(UIImage *)getRoundCollage{
// first make imageViewHolder as circular view
self.imageViewHolder.layer.cornerRadius = self.imageViewHolder.frame.size.width/2;
self.imageViewHolder.clipsToBounds = YES;
// now take screen shot of imageView
UIGraphicsBeginImageContext(self.imageViewHolder.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.imageViewHolder.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
查看结果
如果你喜欢我的回答。那么别忘了为我的答案投票
我需要在一个圆圈中绘制四组图像,每季度相等。 任何人都可以帮助我下面是屏幕
你只需要加一个view
,比如200*200
然后向此视图添加 4 imageviw
然后设置cornerRadius
self.testview.layer.cornerRadius = 100;
self.testview.layer.masksToBounds = YES;
我刚刚设置了背景颜色,看起来像这样
您可以按照以下步骤来实现。 根据附加图像在 .xib 中创建一个视图。我创建了一个视图 "imageViewHolder"。其中有四个 UIImageView。因为我有四个图像都是白色背景,所以我使用了 2 个黑色标签并将它们用作行分隔符位图像。你可以根据你的要求使用任何颜色。
将 IBoutlet 设置为 ImageViewHolder 根据您的要求编辑以下代码
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// first make imageViewHolder round
[self getRoundCollage];
}
-(UIImage *)getRoundCollage{
// first make imageViewHolder as circular view
self.imageViewHolder.layer.cornerRadius = self.imageViewHolder.frame.size.width/2;
self.imageViewHolder.clipsToBounds = YES;
// now take screen shot of imageView
UIGraphicsBeginImageContext(self.imageViewHolder.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.imageViewHolder.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
查看结果
如果你喜欢我的回答。那么别忘了为我的答案投票