
正文
iOS控件圆角与半圆角
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
开发过程中难免用到圆角以及恶心的半圆角,看代码
半圆角:这是把左边的两个角切成了圆角
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:btn.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft) cornerRadii:CGSizeMake(itemHeight/2,itemHeight/2)];//圆角大小
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = btn.bounds;
maskLayer.path = maskPath.CGPath;
btn.layer.mask = maskLayer;
圆角比较容易
_label.clipsToBounds = YES;
_label.layer.cornerRadius =3;







