項目中經(jīng)常會遇到設(shè)置一個view兩個圓角的問題,代碼如下:
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_bgView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(13, 13)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = _bgView.bounds;
maskLayer.path = maskPath.CGPath;
_bgView.layer.mask = maskLayer;
代碼中是給_bgVIew設(shè)置上面的兩個角為13的圓角,_bgVIew背景顏色是白色的
當你設(shè)置完這個之后,在次修改_bgView的時候,就會出現(xiàn)問題,比如去加大_bgview的高度,那么就會出現(xiàn)如圖所示的問題:
正常情況:

1547717699320.jpg
修改_bgView高度之后,出現(xiàn)異常情況:

WX20190117-173633@2x.png
如圖所示,設(shè)置兩個圓角之后,在修改_bgView的高度就會出現(xiàn),顯示錯誤,藍色區(qū)域
解決辦法:
修改_bgVIew高度之后,在重新給_bgView設(shè)置一次兩個圓角