iOS 8及以上实现毛玻璃效果

下面是来客网 jb51.cc 通过网络收集整理的代码片段。

来客网小编现在分享给大家,也给大家做个参考。

#import "ViewController.h"
#import "ILTranslucentView.h"
#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view,typically from a nib.
    [scrollView setContentSize:CGSizeMake(self.view.frame.size.width,self.view.frame.size.height*2)];
//    [self initWithILTranslucentView];
    [self initWithVisualEffectView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)initWithILTranslucentView
{
    ILTranslucentView *translucentView = [[ILTranslucentView alloc] initWithFrame:CGRectMake(0.0,(self.view.frame.size.height - 100.0)/2,320,100.0)];
    translucentView.translucentAlpha = 1.0;
    translucentView.translucentStyle = UIBarStyleDefault;
    translucentView.translucentTintColor = [UIColor clearColor];
    translucentView.backgroundColor = [UIColor clearColor];
    
    [self.view addSubview:translucentView];
}

- (void)initWithVisualEffectView
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0,30.0,self.view.frame.size.width,200.0)];
//    [view setBackgroundColor:[UIColor whiteColor]];
//    [view.layer setShadowOffset:CGSizeMake(-2.0,-2.0)];
//    [view.layer setShadowPath:[[UIBezierPath bezierPathWithRect:CGRectMake(0.0,0.0,view.bounds.size.width + 4.0,view.bounds.size.height + 4.0)] CGPath]];
//    [view.layer setShadowColor:[[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.5] CGColor]];
//    [view.layer setShadowOpacity:0.5];
    [self.view addSubview:view];
    
    UIVisualEffect *blurEffect;
    blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
    UIVisualEffectView *visualEffectView;
    visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    
    [visualEffectView setFrame:view.bounds];
    [view addSubview:visualEffectView];
}

@end

以上是来客网(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。

以上是来客网为你收集整理的iOS 8及以上实现毛玻璃效果全部内容,希望文章能够帮你解决iOS 8及以上实现毛玻璃效果所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。