1.
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"IMG_0004"]]; imageView.frame = CGRectMake(0, 0,320, 720); [self.view addSubview:imageView]; //ios8下添加高斯模糊,模糊有3种类型 UIVisualEffectView *effectView = [[UIVisualEffectView alloc]initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]]; effectView.frame = CGRectMake(0, 100, 320, 100); [imageView addSubview:effectView]; // UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem]; btn.frame = CGRectMake(10, 50, 100, 40); btn.backgroundColor = [UIColor cyanColor]; [btn setTitle:@"btn" forState:UIControlStateNormal]; [effectView.contentView addSubview:btn];
2.
UIImageView *showView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; showView.image = [UIImage imageNamed:@"IMG_0003"]; [self.view addSubview:showView]; // 截取的view,设置NO透明度为0,Yes透明度为1 UIView *snap1 = [showView snapshotViewAfterScreenUpdates:NO]; snap1.center = self.view.center; [self.view addSubview:snap1]; NSLog(@"alpha=%f",snap1.alpha);
时间: 2024-11-06 20:00:00