Jef*_*eff 2 core-graphics uibutton cgcontext ios
我真的挖了IFTTT右下角按钮,如图所示(右下角).

我试着玩CGContext和UIBezierPath匹配效果,但我只是不知道得到这个权利.有没有人对如何实现这一点有一些想法/代码?
谢谢!
首先使用CAShapeLayer创建蒙版
CAShapeLayer * shapeLayer = [CAShapeLayer layer];
//Use these to create path
CGMutablePathRef path = CGPathCreateMutable();
// CGPathMoveToPoint
// CGPathAddLines
shapeLayer.path = path;
Run Code Online (Sandbox Code Playgroud)
然后设置按钮的遮罩
yourbutton.layer.mask = shapeLayer
yourbutton.masksToBounds = YES;
Run Code Online (Sandbox Code Playgroud)
视图示例
CAShapeLayer * shapeLayer = [CAShapeLayer layer];
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, nil, 0, CGRectGetHeight(self.testview.frame));
CGPathAddLineToPoint(path, nil, CGRectGetWidth(self.testview.frame), 0);
CGPathAddLineToPoint(path, nil, CGRectGetWidth(self.testview.frame), CGRectGetHeight(self.testview.frame));
CGPathCloseSubpath(path);
shapeLayer.path = path;
self.testview.layer.masksToBounds = YES;
self.testview.layer.mask = shapeLayer;
Run Code Online (Sandbox Code Playgroud)
和屏幕截图:

| 归档时间: |
|
| 查看次数: |
2110 次 |
| 最近记录: |