iOS之简单的毛玻璃效果

一直听说毛玻璃效果,不知道要如何实现,同学找到了一个简单的毛玻璃效果

废话不多说 直接上图 


实现的效果

下面是具体的代码

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"叶梓萱"]];

imageView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height * 0.5);

UIImageView *imageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"12"]];

imageView1.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height * 0.5, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height * 0.5);

[self.view addSubview:imageView1];

[self.view addSubview:imageView];


//核心代码 在这里

UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width * 0.5, [UIScreen mainScreen].bounds.size.height )];

toolbar.alpha = 0.8;

[imageView addSubview:toolbar];


我们 只需初始化一个 UIToolbar (继承与UIView) 对象 因此要将它添加到要用到毛玻璃的效果的ImageView上

此处Frame要具体位置 具体添加 

我仅仅添加到imageView上(叶梓萱那张图)我将它的frame高度延长到第二张图片上

因此第二张图片也是毛玻璃效果的

好了毛玻璃还有很多实现方法 这只是一个简单的毛玻璃效果!!!




最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥ios动画全貌。在这里你可以看...
    每天刷两次牙阅读 8,566评论 6 30
  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌。在这里你可以看...
    F麦子阅读 5,141评论 5 13
  • 话说苹果在iOS7.0之后,很多系统界面都使用了毛玻璃效果,增加了界面的美观性,比如下图的通知中心界面; 效果图:...
    Mr_董阅读 1,316评论 0 0
  • 1、设置UILabel行间距 NSMutableAttributedString* attrString = [[...
    FF_911阅读 1,417评论 0 3
  • 1、设置UILabel行间距 NSMutableAttributedString* attrString = [[...
    十年一品温如言1008阅读 1,709评论 0 3