Ios 使用核心图形创建具有轮廓的图像
我需要帮助来创建类似以下内容的图像:Ios 使用核心图形创建具有轮廓的图像,ios,objective-c,xcode,ios8,core-graphics,Ios,Objective C,Xcode,Ios8,Core Graphics,我需要帮助来创建类似以下内容的图像: 如果创建UIView的子类,例如CustomView,则只需实现drawRect:方法: - (void)drawRect:(CGRect)rect { [super drawRect:rect]; // set fill & stroke color [[UIColor blueColor] setStroke]; [[UIColor purpleColor] setFill]; // create bl
如果创建
UIView
的子类,例如CustomView
,则只需实现drawRect:
方法:
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
// set fill & stroke color
[[UIColor blueColor] setStroke];
[[UIColor purpleColor] setFill];
// create blocks
CGFloat blockWidth = self.bounds.size.width / 3;
CGFloat blockHeight = self.bounds.size.height;
for (int i = 0; i < 3; i++) {
UIBezierPath *path = [UIBezierPath bezierPathWithRect:
CGRectMake(blockWidth * i, 0, blockWidth, blockHeight);
path.lineWidth = 2;
[path fill];
[path stroke];
}
}
-(void)drawRect:(CGRect)rect{
[超级drawRect:rect];
//设置填充和笔划颜色
[[UIColor blueColor]设定行程];
[[UIColor purpleColor]setFill];
//创建块
CGFloat blockWidth=self.bounds.size.width/3;
CGFloat blockHeight=self.bounds.size.height;
对于(int i=0;i<3;i++){
UIBezierPath*路径=[UIBezierPath bezierPathWithRect:
CGRectMake(块宽度*i,0,块宽度,块高度);
path.lineWidth=2;
[路径填充];
[路径笔划];
}
}
谢谢您的回答,我需要将该视图转换为图像。目前它对我有效。这相当简单:我找到了一些代码。但是如果是这样,您最好使用GIMP之类的绘图程序。