我需要使用Objective C在UIView上绘制模糊效果。
这是我的设计
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle: UIBlurEffectStyleExtraLight];
UIVisualEffectView *contentView = [[UIVisualEffectView alloc] initWithEffect: blurEffect];
contentView.layer.cornerRadius = 18.0;
contentView.layer.masksToBounds = YES;
contentView.backgroundColor = [UIColor whiteColor];
contentView.userInteractionEnabled = NO;
contentView.layer.shadowRadius = 10;
contentView.layer.shadowOpacity = 0.2f;
contentView.layer.shadowColor = [UIColor whiteColor].CGColor;
contentView.layer.shadowOffset = CGSizeZero;
[contentView setFrame: annotationFrame];
[contentView setTranslatesAutoresizingMaskIntoConstraints: YES];
self.contentView = contentView;
下面的屏幕截图是使用上述代码的当前输出
我已经尝试了上面的代码。 ,但是我没有得到确切的模糊效果 请建议我绘制此设计。
我更新了以下代码
- (void)drawRect:(CGRect)rect {
[super drawRect: rect]; //i doubt we need a super drarRect here…
[self drawMarker: self.markerView fillColor: [UIColor whiteColor]];
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGPathRef path = CGPathCreateWithRoundedRect(CGRectInset(rect, self.frame.size.width/4, self.frame.size.height/4), self.frame.size.width/8, self.frame.size.height/8, nil);
CGContextSetFillColorWithColor(ctx,[UIColor slateColor].CGColor);
CGContextSetShadowWithColor(ctx, CGSizeZero, self.frame.size.height/4, [UIColor slateColor].CGColor);
for ( int i = 0; i<=6; i++) {
CGContextAddPath(ctx, path);
CGContextFillPath(ctx);
}
}
我需要视图后的模糊效果,请为此向我提出建议。
谢谢。
答案 0 :(得分:1)
将我先前的答案从迅速转变为Objective-C,我们有了
private class MakeRequestTask extends AsyncTask<Void, Void, List<String>> {
private Exception mLastError = null;
MakeRequestTask() {
//Some stuff
}
@Override
protected List<String> doInBackground(Void... params) {
//Some stuff
}
@Override
protected void onPreExecute() {
//Some stuff
}
@Override
protected void onPostExecute(List<String> output) {
// swipe layout will not be shown if fragment is not visible or destroyed
if(isFragmentVisible){
swipeRefreshLayout.setRefreshing(false);
}
// toast will be shown no matter what fragment is visible
Toast.makeText(getActivity(), "TO_DISPLAY", Toast.LENGTH_SHORT).show();
}
@Override
protected void onCancelled() {
if(isFragmentVisible){
swipeRefreshLayout.setRefreshing(false);
}
//Some stuff
}
}
答案 1 :(得分:0)
查看以下我用于模糊效果的参考:
https://dzone.com/articles/applying-gaussian-blur-to-uiviews-with-swift-proto
这仅适用于高斯模糊效果。