【发布时间】:2017-12-24 11:49:20
【问题描述】:
我知道画圆的代码。但我不知道如何制作褪色尺寸:
- (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 及更高版本。谢谢!
【问题讨论】:
-
使用 CIFilter。
标签: ios objective-c drawrect