iOS7默认支持毛玻璃效果,只对navBar,tabBar等系统控件有效。如果要对自定义控件实现毛玻璃效果需要做下面几步操作
UIScrollView
滚动条在scrollerView中的位置
UIScrollView
视图在scrollView中的位置
是否自动设置UIScrollView
的contentInset
。设置为NO
,自定义的contentInset
才会生效
self.automaticallyAdjustsScrollViewInsets=NO;
有两种方法实现毛玻璃效果
- 生成毛玻璃效果的图片
https://developer.apple.com/library/ios/samplecode/UIImageEffects/Introduction/Intro.html
- UIVisualEffectView
self.backgroundColor = [UIColor clearColor];
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
[self addSubview:effectview];