毛玻璃效果
1.UIVisualEffectView 类
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];//此为枚举,包含多种效果
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; //这个类可以干很多东西,对照片可以进行简单的处理!
effectView.frame = self.imageV.bounds;
[self.imageV addSubview:effectView];
effectView.alpha = .8f;//透明度慎用,一般设置为1
2.利用大神封装的FXBluerView ,效果很好,但耗炸CUP。
程序内截屏
说到截屏,网上放了方法,但如果需要截屏的视图包含了GIF就截不到了,无语!找了好久,感觉这方面的资源太少了,今天我就稍微小总结一下!!
什么私有API就不介绍了,用了也上不了!
1.iOS7 之前的方法,适用于大多数的截屏方法
```
+ (UIImage *)screenShotForView:(UIView *)view {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0); //大小,透明,缩放
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
```
2.iOS7出现的方法(推荐,支持GIF)
+ (UIImage *)screenShotForView:(UIView *)view {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; //据测试如果是YES 会有白光,类似 HOME+Power键的截屏效果
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
3.指定截取区域
+ (UIImage *)screenShotForView:(UIView *) View frame:(CGRect)frame {
UIGraphicsBeginImageContext(theView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
UIRectClip(frame);
[view.layer renderInContext:context];
// [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
网友评论