-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIView+ExpandView.m
More file actions
33 lines (26 loc) · 1.05 KB
/
UIView+ExpandView.m
File metadata and controls
33 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// UIView+ExpandView.m
// CKExpandView
//
// Created by C.K on 9/21/15.
// Copyright © 2015 chenkun. All rights reserved.
//
#import "UIView+ExpandView.h"
@implementation UIView (ExpandView)
- (void)expand
{
UIBezierPath* aPath = [UIBezierPath bezierPath];
aPath.lineCapStyle = kCGLineCapRound;
aPath.lineJoinStyle = kCGLineCapRound;
CGSize size = self.bounds.size;
[aPath moveToPoint:CGPointMake(size.width / 2, 0)];
[aPath addQuadCurveToPoint:CGPointMake(size.width, size.height / 2) controlPoint:CGPointMake(size.width, 0)];
[aPath addQuadCurveToPoint:CGPointMake(size.width / 2, size.height) controlPoint:CGPointMake(size.width, size.height)];
[aPath addQuadCurveToPoint:CGPointMake(0, size.height / 2) controlPoint:CGPointMake(0, size.height)];
[aPath addQuadCurveToPoint:CGPointMake(size.width / 2, 0) controlPoint:CGPointMake(0, 0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.bounds;
maskLayer.path = aPath.CGPath;
self.layer.mask = maskLayer;
}
@end