ios毛玻璃效果
来源:互联网 发布:mac安装win10不要u盘 编辑:程序博客网 时间:2024/05/28 06:08
#import "ViewController.h"#import "UIImage+ImageEffects.h"@interface ViewController ()
// 点击手势@property (strong, nonatomic) IBOutlet UITapGestureRecognizer *tapGesture;
// 背景图片@property (weak, nonatomic) IBOutlet UIImageView *bgImage;
// 图层@property (strong, nonatomic) CALayer *layer;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad];
self.bgImage.userInteractionEnabled = YES; [self.tapGesture addTarget:self action:@selector(tapBacegroundImage)];}- (void)tapBacegroundImage{ self.layer = [CALayer layer]; self.layer.frame = CGRectMake(0, 0, CGRectGetWidth(self.bgImage.frame), CGRectGetHeight(self.bgImage.frame)); [self.view.layer addSublayer:self.layer]; float scale = [UIScreen mainScreen].scale;
// <span style="white-space:pre"></span>0.0表示 <span style="font-family: Arial, Helvetica, sans-serif;">[UIScreen mainScreen].scale</span>
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, YES, 0.0);
// 用于毛玻璃的截屏 [self.view drawViewHierarchyInRect:self.view.frame afterScreenUpdates:NO]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(CGRectGetMinX(self.layer.frame) * scale, CGRectGetMinY(self.layer.frame) * scale, CGRectGetWidth(self.layer.frame) * scale, CGRectGetHeight(self.layer.frame) * scale)); image = [UIImage imageWithCGImage:imageRef]; CGImageRelease(imageRef); image = [image applyBlurWithRadius:50.0f tintColor:[UIColor colorWithWhite:1 alpha:0.1] saturationDeltaFactor:1.0f maskImage:nil]; self.layer.contents = (__bridge id)(image.CGImage); }
0 0
- iOS 毛玻璃效果
- ios 毛玻璃效果
- iOS 图片毛玻璃效果
- IOS毛玻璃效果
- ios毛玻璃效果
- iOS:毛玻璃效果
- iOS毛玻璃效果
- iOS 毛玻璃效果
- ios毛玻璃效果
- iOS毛玻璃效果
- iOS开发 - 毛玻璃效果
- iOS 毛玻璃效果
- IOS毛玻璃效果
- iOS毛玻璃效果
- 毛玻璃效果iOS
- ios 毛玻璃效果
- iOS 毛玻璃效果参考
- iOS毛玻璃效果实现
- OOAD 学习笔记 七
- lightoj 1104(期望)
- 浅析SAT Math 考题增量
- Eclipse开发tomcat 常用配置
- freemarker中页面直接可以使用的内置对象
- ios毛玻璃效果
- I Think I Need a Houseboat
- 在迁移或者升级项目文件后经常会遇到C1083解决方法
- 【BZOJ3566】【SHOI2014】概率充电器 树形DP 概率DP
- Android权限和动作大全
- iOS UISearchBar 搜索功能
- sublime自动缩进排版
- Button onClick事件一种新的写法
- Miner3D Professional可视化数据分析方案