max*_*ax_ 6 iphone xcode objective-c quartz-graphics ios4
我想在UIView周围绘制一个发光的边框,距离实际的UIView本身大约是5px.
请问你能告诉我怎么做到这一点?
e.J*_*mes 13
可能最简单的方法是创建一个阴影,但使用浅色而不是暗色.阴影细节可以在这里找到:如何在UIView下绘制阴影?和这里.
像这样的东西应该让球滚动:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextSetShadowWithColor(context, CGSizeMake(0, 0), 10,
[UIColor whiteColor].CGColor);
[super drawRect:rect];
CGContextRestoreGState(context);
}
Run Code Online (Sandbox Code Playgroud)
更新:我刚试了这个.您必须在发光视图的超级视图上使用此代码才能正常工作.