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;