我想画出这样的形状如何绘制模糊形状?
我知道绘制圆的代码。但我不知道如何使褪色大小:
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(c, YES);
// Fill background
CGContextSetFillColorWithColor(c, [UIColor colorWithWhite:1 alpha:1].CGColor);
CGContextAddRect(c, CGRectMake(0, 0, rect.size.width, rect.size.height));
CGContextFillPath(c);
// Dark inside
if (_type == LDConstrainTypeCircle) {
CGContextAddEllipseInRect(c, self.blurRect);
CGContextClip(c);
}
CGContextSetFillColorWithColor(c, [UIColor blackColor].CGColor);
CGContextAddRect(c, self.blurRect);
CGContextFillPath(c);
}
如何使图像这样。我的项目是针对iOS 7.0和更高版本的。谢谢!
请尝试在这里https://stackoverflow.com/questions/30953201/adding-blur-effect-to-background-in-swift/39887516#39887516 –
使用CIFilter。 – matt