設(shè)置毛玻璃的效果,可以實(shí)例化UIToolbar來實(shí)現(xiàn)。設(shè)置它的frame以及barstyle屬性即可柒桑,如果不滿意效果,還可以設(shè)置toolbar的alpha噪舀,代碼很簡單魁淳。直接貼代碼了
可以看出UIBarStyleBlackOpaque以及UIBarStyleBlackTranslucent被棄用,那么用UIBarStyleDefault以及UIBarStyleBlack就行与倡。
typedefNS_ENUM(NSInteger, UIBarStyle) {
UIBarStyleDefault=0,
UIBarStyleBlack=1,
UIBarStyleBlackOpaque=1,// Deprecated. Use UIBarStyleBlack
UIBarStyleBlackTranslucent =2,// Deprecated. Use UIBarStyleBlack and set the translucent property to YES
}__TVOS_PROHIBITED;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
imageView.image = [UIImage imageNamed:@"測試用圖片"];
[self.view addSubview:imageView];
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:self.view.bounds];
toolbar.barStyle = UIBarStyleDefault;
toolbar.alpha =0.8;
[imageView addSubview:toolbar];
實(shí)現(xiàn)出來的效果圖如下: