毛玻璃效果
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;?
}