博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
利用mask layer 勾View
阅读量:4684 次
发布时间:2019-06-09

本文共 1049 字,大约阅读时间需要 3 分钟。

  1. #define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width  
  2. #define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height  
  3.   
  4. - (void)addMask{  
  5.     UIButton * _maskButton = [[UIButton alloc] init];  
  6.     [_maskButton setFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];  
  7.     [_maskButton setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.7]];  
  8.     [self.view addSubview:_maskButton];  

 

  1.       //把下面代码加入到view的-drawRect'中便可以实现
  2.     //create path  
  3.     UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];  
  4.       
  5.     // MARK: circlePath  
  6.     [path appendPath:[UIBezierPath bezierPathWithArcCenter:CGPointMake(SCREEN_WIDTH / 2, 200) radius:100 startAngle:0 endAngle:2*M_PI clockwise:NO]];  
  7.       
  8.     // MARK: roundRectanglePath  
  9.     [path appendPath:[[UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 400, SCREEN_WIDTH - 200100) cornerRadius:15] bezierPathByReversingPath]];  
  10.       
  11.     CAShapeLayer *shapeLayer = [CAShapeLayer layer];  
  12.       
  13.     shapeLayer.path = path.CGPath;  
  14.       
  15.     [_maskButton.layer setMask:shapeLayer];  
  16. }

转载于:https://www.cnblogs.com/xiguapijiamuguanaicha/p/5416264.html

你可能感兴趣的文章
安卓客户端 扫描二维码登陆
查看>>
以SEO的角度分析使用iframe框架所存在的优缺点
查看>>
MOSS 文档库操作类
查看>>
PHP - 接口 - 单一接口
查看>>
算法学习-哈希表
查看>>
揭秘webdriver实现原理
查看>>
技术网站汇总
查看>>
课后题:冲激函数习题讨论
查看>>
hdu1232 畅通工程 并查集的 应用
查看>>
JavaScript 数据类型检测总结
查看>>
克隆数组的几种方式?
查看>>
什么是XMLA-- XML for Analysis
查看>>
Sharepoint2013商务智能学习笔记之使用Current User Filter筛选Excel 数据(六)
查看>>
2012-11-13:延期通知书
查看>>
CodeForces - 367C Sereja and the Arrangement of Numbers
查看>>
js添加文件引用,可以智能感知
查看>>
大数据学习——VMware安装
查看>>
[BZOJ2125]最短路
查看>>
对象和数组的相互转化
查看>>
为什么存储过程比sql语句效率高?
查看>>