设置毛玻璃的效果,可以实例化UIToolbar来实现。设置它的frame以及barstyle属性即可,如果不满意效果,还可以设置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];
实现出来的效果图如下:
UIBarStyleDefault UIBarStyleBlack
网友评论