您的位置:首页 > 产品设计 > UI/UE

iOS8 模糊视图(毛玻璃效果) UIVisualEffectView

2015-05-23 11:30 423 查看
在需要模糊的UIView上,添加一个UIVisualEffectView对象即可,若直接在storyboad里面直接加UIVisualEffectView,你的项目必须是iOS8以上才能用

- (void)viewDidLoad {

[super
viewDidLoad];

// UIImageView *imageview = [[UIImageView alloc] init];

//

// imageview.frame = CGRectMake(10, 200, 300, 300);

//

// imageview.image = [UIImage imageNamed:@"2"];

//

// imageview.contentMode = UIViewContentModeScaleAspectFit;

//

// imageview.userInteractionEnabled = YES;

//

// [self.view addSubview:imageview];

UIBlurEffect *blur = [UIBlurEffect
effectWithStyle:UIBlurEffectStyleLight];

UIVisualEffectView *effectview = [[UIVisualEffectView
alloc]
initWithEffect:blur];

// effectview.frame = CGRectMake(0, 0, imageview.frame.size.width/2, 300);

effectview.frame =
CGRectMake(0,
0, self.view.frame.size.width,
self.view.frame.size.height);

//[imageview addSubview:effectview];
[self.view
addSubview:effectview];

UIButton *btn = [UIButton
buttonWithType:UIButtonTypeSystem];

btn.frame =
CGRectMake(10,
50, 100,
40);

[btn setTitle:@"btn"
forState:UIControlStateNormal];

[effectview.contentView
addSubview:btn];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: