UIImageView四個角加不同的圓角的方法

- (void)setCornerRadiusWithTopLeft:(CGFloat)topLefttopRight:(CGFloat)topRightbottomLeft:(CGFloat)bottomLeftbottomRight:(CGFloat)bottomRightimageView:(UIImageView*)imageView{

? ? CGFloatminX =CGRectGetMinX(imageView.bounds);

? ? CGFloatminY =CGRectGetMinY(imageView.bounds);

? ? CGFloatmaxX =CGRectGetMaxX(imageView.bounds);

? ? CGFloatmaxY =CGRectGetMaxY(imageView.bounds);

? ? CGFloattopLeftCenterX = minX + topLeft;

? ? CGFloattopLeftCenterY = minY + topLeft;

? ? CGFloattopRightCenterX = maxX - topRight;

? ? CGFloattopRightCenterY = minY + topRight;

? ? CGFloatbottomLeftCenterX = minX + bottomLeft;

? ? CGFloatbottomLeftCenterY = maxY - bottomLeft;

? ? CGFloatbottomRightCenterX = maxX - bottomRight;

? ? CGFloatbottomRightCenterY = maxY - bottomRight;

? ? UIBezierPath *path = [UIBezierPath bezierPath];

? ? [pathaddArcWithCenter:CGPointMake(topLeftCenterX, topLeftCenterY)radius:topLeftstartAngle:M_PIendAngle:3*M_PI/2.0clockwise:YES];

? ? [pathaddArcWithCenter:CGPointMake(topRightCenterX, topRightCenterY)radius:topRightstartAngle:3*M_PI/2.0endAngle:0clockwise:YES];

? ? [pathaddArcWithCenter:CGPointMake(bottomRightCenterX, bottomRightCenterY)radius:bottomRightstartAngle:0endAngle:M_PI_2clockwise:YES];

? ? [pathaddArcWithCenter:CGPointMake(bottomLeftCenterX, bottomLeftCenterY)radius:bottomLeftstartAngle:M_PI_2endAngle:M_PIclockwise:YES];

? ? CAShapeLayer*masklayer = [[CAShapeLayeralloc]init];

? ? masklayer.frame= imageView.bounds;

? ? masklayer.path= path.CGPath;

? ? imageView.layer.mask= masklayer;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容