iOS系列UI篇——UIVisualEffectView
来源:互联网 发布:苹果接电话变声软件 编辑:程序博客网 时间:2024/05/22 14:22
这是一个iOS 8.0才出来的效果——毛玻璃~现在很多APP都已经在用了,从用户体验这个角度来说,确实更能直接的吸收到用户眼球!功能比较简单,直接上代码
#import "ViewController.h"#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height@interface ViewController (){ UIBlurEffect * _eff; UIVisualEffectView * _vev;}@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; //创建一个背景图片 UIImageView * imageView = [[UIImageView alloc] initWithFrame:(CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT))]; [imageView setImage:[UIImage imageNamed:@"1"]]; [self.view addSubview:imageView]; //设置效果style /* UIBlurEffectStyleExtraLight, 高亮 UIBlurEffectStyleLight, 一般 UIBlurEffectStyleDark 暗 */ _eff = [UIBlurEffect effectWithStyle:(UIBlurEffectStyleLight)]; //在UIVisualEffectView加上这个效果 _vev = [[UIVisualEffectView alloc] initWithEffect:_eff]; _vev.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 2); [self.view addSubview:_vev]; UIButton * button = [[UIButton alloc] initWithFrame:(CGRectMake((_vev.frame.size.width - 50)/2, (_vev.frame.size.height - 50) / 2, 50, 50))]; button.backgroundColor = [UIColor redColor]; button.alpha = 0.3; [button addTarget:self action:@selector(buttonClicked:) forControlEvents:(UIControlEventTouchUpInside)]; [_vev addSubview:button];}- (void)buttonClicked:(UIButton *)sender{ //改变透明度 if (_vev.alpha >= 0.1f) { _vev.alpha -= 0.01f; }}
0 0
- iOS系列UI篇——UIVisualEffectView
- iOS学习之—— UIVisualEffectView
- iOS系列UI篇——UIButton
- iOS系列UI篇——UIControl
- iOS系列UI篇——UITextField
- iOS系列UI篇——UITextView
- ios系列UI篇——UISwitch
- iOS系列UI篇——UIImageView
- iOS系列UI篇——自定义UIButton
- iOS系列UI篇——UIDatePicker和UIPickerView
- UIVisualEffectView
- UIVisualEffectView
- iOS-UIKit( UIVisualEffectView.h - -解读)
- [IOS 开发] 使用UIVisualEffectView实现模糊效果
- iOS开发UI篇—APP主流UI框架结构
- iOS开发UI篇—APP主流UI框架结构
- iOS开发UI篇—APP主流UI框架结构
- iOS --- UI系列之UIAlertController
- 第十二周项目三:图遍历算法实现
- c语言输入生日显示星座
- 2 Which of the following cannot be used as input to the SQL Tuning Advisor? (Choose all that apply.)
- SVN服务器迁移客户端配置更改说明【Windows & Mac】
- spring框架初步了解(第二篇)
- iOS系列UI篇——UIVisualEffectView
- JSON使用ObjectCreationHandling 反序列化替换不重复的值
- Xcode7使用MJ的NSObject+Value出现Too many arguments to function call,expected 0,have 3
- c语言输入菱形
- android中的Handler和Callback机制
- 第十二周项目4-利用遍历思想求解图问题(7)
- js中typeof的用法汇总
- 编程判断3人中谁的年龄最大,并打印最大者的年龄
- 第四周 项目四 建设双链表算法库