绘制特殊图形
作者:互联网
//设置视图位置和大小 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];指定圆角
标签:圆角,特殊,设置,CAShapeLayer,bounds,maskLayer,myView,图形,绘制 来源: https://www.cnblogs.com/kingstudy/p/11576332.html