[英]Transparent Navigation Bar with blur TableView Scroll Offset
我正在尝试创建这种效果。
仅在滚动偏移视图上模糊效果
我尝试以编程方式执行以下操作
- (void)addBlurEffect {
// Add blur view
// CGRect statusBarViewRect = [[UIApplication sharedApplication] statusBarFrame];
CGRect bounds = self.bounds;
/*to extwnd from status bar till the end of navigation bar height*/
CGRect aRect = CGRectMake(0, self.frame.origin.y-40, self.frame.size.width, bounds.size.height+20);
/*Make a blur view*/
UIVisualEffectView *visualView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
/*Assign a tag to make it accessable from view hirarchy*/
visualView.tag = 10000;
visualView.frame = aRect;
visualView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:visualView];
self.backgroundColor = [UIColor colorWithRed:42.0f green:152.0f blue:231.0f alpha:0.7f];
[self sendSubviewToBack:visualView];
/*back button was disabled following enables it*/
visualView.userInteractionEnabled = false;
}
我无法重新创建UI。 这就是我得到的UIEffectView添加了渐变效果。
渐变效果而不是清晰的视野。 如何重新创建所需的UI效果?
试试这个:-self.tableView.contentInset = UIEdgeInsetsMake(44,0,0,0);
使用此选项可以添加模糊效果进行查看。
var blurEffectView:UIVisualEffectView!
func addblurEffectToView()
{
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds
blurEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] // for supporting device rotation
blurEffectView.alpha = 1
view.addSubview(blurEffectView)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.