zoukankan      html  css  js  c++  java
  • iOS 7 Pushing the Limits Notes

    Problem:

    How to create a layer that looks like your notification center's or control center's background

    Solution:

    Using UIImage+ImageEffects to Create a Blurred Popup Layer

    Code Fragments:

    // create the layer
    self.layer = [CALayer layer];
    self.layer.frame = CGRectMake(80, 100, 160, 160);
    [self.view.layer addSublayer:self.layer];
    // Take the screenshot
    float scale = [UIScreen mainScreen].scale;
    UIGraphicsBeginImageContextWithOptions(self.view.frame.size, YES, scale);
    [self.view drawViewHierarchyInRect:self.view.frame afterScreenUpdates:NO];
    __block UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    // Crop the screenshot
    CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage,
    CGRectMake(self.layer.frame.origin.x * scale,
    self.layer.frame.origin.y * scale,
    self.layer.frame.size.width * scale,
    self.layer.frame.size.height * scale));
    image = [UIImage imageWithCGImage:imageRef];
    // Apply the effect
    image = [image applyBlurWithRadius:50.0f
    tintColor:
    [UIColor colorWithRed:0 green:1 blue:0 alpha:0.1]
    saturationDeltaFactor:2
    maskImage:nil];
    // assign it to the new layer's contents
    self.layer.contents = (__bridge id)(image.CGImage);
  • 相关阅读:
    控制器的功能和工作原理
    数据通路的功能和基本结构
    指令的执行过程
    CPU的功能和基本组成结构
    CSS介绍
    html内容
    web简单介绍
    事务隔离机制介绍
    多版本并发控制MVCC
    数据库锁机制
  • 原文地址:https://www.cnblogs.com/davidgu/p/3912716.html
Copyright © 2011-2022 走看看