iOS 8 蘋果開放了毛玻璃效果的控件UIBlurEffect和UIVisualEffectView
// 毛玻璃視圖
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
effectView.frame = CGRectMake(0, 0, 375, 500);
[self.view addSubview:effectView];
系統(tǒng)提供的毛玻璃類型
UIBlurEffectStyleExtraLight,
UIBlurEffectStyleLight,
UIBlurEffectStyleDark
亮色和黑色威始,但是有時(shí)候這些樣式并不能滿足項(xiàng)目中UI的需求
問題:如何自定義自己想要的顏色?
當(dāng)改變系統(tǒng)樣式的時(shí)候萧恕,查看圖層,發(fā)現(xiàn)一個(gè)_UIVisualEffectFilterView控件的背景顏色發(fā)生了改變夷陋。試著改變_UIVisualEffectFilterView的背景顏色柱恤。
for (UIView *view in effectView.subviews) {
if ([view isKindOfClass:NSClassFromString(@"_UIVisualEffectFilterView")]) {
view.backgroundColor = [UIColor colorWithRed:83/255.0 green:24/255.0 blue:79/255.0 alpha:0.8];
}
}
效果圖
自定義毛玻璃樣式.png
注意:顏色需要透明度,不然看不到下面的的圖層拷况。
===========================================
喜歡我就點(diǎn)我吧