借鉴https://www.jianshu.com/p/ce40459e27f4
#import<UIKit/UIKit.h>@interfaceUIView(LSCore)#pragma mark - 设置部分圆角/**
* 设置部分圆角(绝对布局)
*
* @param corners 需要设置为圆角的角 UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerAllCorners
* @param radii 需要设置的圆角大小 例如 CGSizeMake(20.0f, 20.0f)
*/- (void)addRoundedCorners:(UIRectCorner)corners withRadii:(CGSize)radii;/**
* 设置部分圆角(相对布局)
*
* @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;@end
作者:王隆帅
链接:https://www.jianshu.com/p/ce40459e27f4
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
import"UIView+LSCore.h"@implementationUIView(LSCore)#pragma mark - 设置部分圆角/**
* 设置部分圆角(绝对布局)
*
* @param corners 需要设置为圆角的角 UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerAllCorners
* @param radii 需要设置的圆角大小 例如 CGSizeMake(20.0f, 20.0f)
*/- (void)addRoundedCorners:(UIRectCorner)corners withRadii:(CGSize)radii {UIBezierPath* rounded = [UIBezierPathbezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:radii];CAShapeLayer* shape = [[CAShapeLayeralloc] 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 = [UIBezierPathbezierPathWithRoundedRect:rect byRoundingCorners:corners cornerRadii:radii];CAShapeLayer* shape = [[CAShapeLayeralloc] init]; [shape setPath:rounded.CGPath];self.layer.mask = shape;}@end
作者:王隆帅
链接:https://www.jianshu.com/p/ce40459e27f4
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
- (UIImageView*)blackBGimageView {if(!_blackBGimageView) { _blackBGimageView = [[UIImageViewalloc] init]; _blackBGimageView.backgroundColor = black_color; _blackBGimageView.alpha =0.7; [_blackBGimageView addRoundedCorners:UIRectCornerBottomLeft|UIRectCornerBottomRightwithRadii:CGSizeMake(5.0,5.0) viewRect:CGRectMake(0,0, ((SCREEN_WIDTH -4*10)/2.0),35)]; }return_blackBGimageView;}
作者:王隆帅
链接:https://www.jianshu.com/p/ce40459e27f4
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
网友评论