| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- //
- // UIView+Voice.m
- // UniversalApp
- //
- // Created by bogokj on 2019/12/16.
- // Copyright © 2019 voidcat. All rights reserved.
- //
- #import "UIView+Voice.h"
- @implementation UIView (Voice)
- /**
- * 设置部分圆角(绝对布局)
- *
- * @param corners 需要设置为圆角的角 UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerAllCorners
- * @param radii 需要设置的圆角大小 例如 CGSizeMake(20.0f, 20.0f)
- */
- - (void)addRoundedCorners:(UIRectCorner)corners
- withRadii:(CGSize)radii {
-
- UIBezierPath* rounded = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:radii];
- CAShapeLayer* shape = [[CAShapeLayer alloc] init];
- [shape setPath:rounded.CGPath];
-
- self.layer.mask = shape;
- }
- /**
- * 设置部分圆角(相对布局)
- *
- * @param corners 需要设置为圆角的角 UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerAllCorners
- * @param radii 需要设置的圆角大小 例如 CGSizeMake(20.0f, 20.0f)
- * @param rect 需要设置的圆角view的rect
- */
- - (void)addRoundedCorners:(UIRectCorner)corners
- withRadii:(CGSize)radii
- viewRect:(CGRect)rect {
-
- UIBezierPath* rounded = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:corners cornerRadii:radii];
- CAShapeLayer* shape = [[CAShapeLayer alloc] init];
- [shape setPath:rounded.CGPath];
-
- self.layer.mask = shape;
- }
- - (void)addAppTopCornerRadius{
-
- UIBezierPath* rounded = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(kTopCornerRadius, kTopCornerRadius)];
- CAShapeLayer* shape = [[CAShapeLayer alloc] init];
- [shape setPath:rounded.CGPath];
-
- self.layer.mask = shape;
-
- }
- - (void)addTopCornerRadius:(CGFloat)TopRadius{
-
- UIBezierPath* rounded = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(TopRadius, TopRadius)];
- CAShapeLayer* shape = [[CAShapeLayer alloc] init];
- [shape setPath:rounded.CGPath];
-
- self.layer.mask = shape;
-
- }
- @end
|