UIBezierPath加圆角

来源:互联网 发布:免费自助建站平台源码 编辑:程序博客网 时间:2024/06/15 21:30

    UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];

    button.backgroundColor = [UIColorredColor];

    button.frame =CGRectMake(0,0, 100,44);

    CGRect bounds = button.bounds;

    UIBezierPath *path = [UIBezierPathbezierPathWithRoundedRect:bounds cornerRadius:frame.size.width/2];

    CAShapeLayer *shapeLayer = [CAShapeLayerlayer];

    shapeLayer.frame = bounds;

    shapeLayer.path = path.CGPath;

    button.layer.mask = shapeLayer;

0 0