Skip to content

Latest commit

 

History

History
41 lines (25 loc) · 1.18 KB

visual-effect.md

File metadata and controls

41 lines (25 loc) · 1.18 KB

iOS上实现毛玻璃效果

iOS7默认支持毛玻璃效果,只对navBar,tabBar等系统控件有效。如果要对自定义控件实现毛玻璃效果需要做下面几步操作

scrollIndicatorInsets

UIScrollView滚动条在scrollerView中的位置

contentInset

UIScrollView视图在scrollView中的位置

automaticallyAdjustsScrollViewInsets

是否自动设置UIScrollViewcontentInset。设置为NO,自定义的contentInset才会生效

self.automaticallyAdjustsScrollViewInsets=NO;

自定义View实现毛玻璃效果

有两种方法实现毛玻璃效果

  1. 生成毛玻璃效果的图片

https://developer.apple.com/library/ios/samplecode/UIImageEffects/Introduction/Intro.html

  1. UIVisualEffectView
self.backgroundColor = [UIColor clearColor];
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
[self addSubview:effectview];

相关资料