绘制特殊图形

 //设置视图位置和大小
    UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(15, 300, self.view.bounds.size.width-30, 46)];
    //设置背景颜色
    myView.backgroundColor = [UIColor blackColor];
    //绘制圆角 要设置的圆角 使用“|”来组合
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:myView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(16,16)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    //设置大小
    maskLayer.frame = myView.bounds;
    //设置图形样子
    maskLayer.path = maskPath.CGPath;
    myView.layer.mask = maskLayer;
    //添加
    [self.view addSubview:myView];
指定圆角

猜你喜欢

转载自www.cnblogs.com/kingstudy/p/11576332.html
今日推荐