• 实现毛玻璃效果


    iOS7以来,应用界面上的设计很多都采用了毛玻璃效果

    苹果也放出了实现毛玻璃的分类

    有需要的直接搜索下面的关键字~

    UIImage+ImageEffects.h,简单明了,好看好用

    #import <UIKit/UIKit.h>
    
    @interface UIImage (ImageEffects)
    
    - (UIImage *)applyLightEffect;
    - (UIImage *)applyExtraLightEffect;
    - (UIImage *)applyDarkEffect;
    - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor;
    
    - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
    
    @end

    还有一种就是直接拿NavigationBar的效果自己封装一个视图(跟一个同学聊天的的时候他教我的~)

    @interface SlurImageView ()
    @property (nonatomic, strong) UINavigationBar *slurNavigationbar;
    @end
    
    
    
    @implementation SlurImageView
    
    - (id)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self) {
            // Initialization code
            
            [self setup];
            
        }
        return self;
    }
    
    -(void)awakeFromNib{
        [self setup];
    }
    
    - (void)setup
    {
        // If we don't clip to bounds the toolbar draws a thin shadow on top
        [self setClipsToBounds:YES];
        
        if (!self.slurNavigationbar)
        {
            UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:[self bounds]];
            self.slurNavigationbar = navigationBar;
            [self.layer insertSublayer:self.slurNavigationbar.layer atIndex:0];
        }
    }
    
    
    - (void)layoutSubviews
    {
        [super layoutSubviews];
        
        [self.slurNavigationbar setFrame:[self bounds]];
    }
    
    
    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    - (void)drawRect:(CGRect)rect
    {
        // Drawing code
    }
    */
    
    @end

    iOS8下苹果直接提供了实现毛玻璃效果的API

    UIBlurEffectStyle

    UIBlurEffectStyleView

    看这里:::::   http://www.swiftmi.com/topic/77.html

  • 相关阅读:
    Python基础语法
    理解session和cookie
    应用服务器
    web服务器
    Python正则表达式
    理解HTTP协议
    常见浏览器内核
    python中range()和len()函数区别
    多线程执行测试用例
    selenium+Python(生成html测试报告)
  • 原文地址:https://www.cnblogs.com/xyzaijing/p/4031339.html
Copyright © 2020-2023  润新知