view的指定角设置圆弧

UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(50, 200, 200, 50)];

    view2.backgroundColor = [UIColor greenColor];

    [self.view addSubview:view2];

    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

    maskLayer.frame = view2.bounds;

    maskLayer.path = maskPath.CGPath;

    view2.layer.mask = maskLayer;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以通过在QGraphicsView中使用QPainter绘制同心圆弧。 以下是一个示例代码,绘制3个同心圆弧: ```python from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene from PyQt5.QtGui import QPainter, QColor, QPen, QBrush from PyQt5.QtCore import Qt class MyGraphicsView(QGraphicsView): def __init__(self, parent=None): super(MyGraphicsView, self).__init__(parent) self.scene = QGraphicsScene(self) self.setScene(self.scene) def paintEvent(self, event): painter = QPainter(self.viewport()) # 绘制第一个圆弧 pen = QPen(QColor(255, 0, 0)) pen.setWidth(5) brush = QBrush(QColor(255, 0, 0, 50)) painter.setPen(pen) painter.setBrush(brush) painter.drawArc(50, 50, 200, 200, 0 * 16, 90 * 16) # 绘制第二个圆弧 pen = QPen(QColor(0, 255, 0)) pen.setWidth(5) brush = QBrush(QColor(0, 255, 0, 50)) painter.setPen(pen) painter.setBrush(brush) painter.drawArc(75, 75, 150, 150, 0 * 16, 90 * 16) # 绘制第三个圆弧 pen = QPen(QColor(0, 0, 255)) pen.setWidth(5) brush = QBrush(QColor(0, 0, 255, 50)) painter.setPen(pen) painter.setBrush(brush) painter.drawArc(100, 100, 100, 100, 0 * 16, 90 * 16) if __name__ == '__main__': import sys from PyQt5.QtWidgets import QApplication app = QApplication(sys.argv) view = MyGraphicsView() view.show() sys.exit(app.exec_()) ``` 在这个示例中,使用QPen和QBrush来设置圆弧的颜色和填充颜色。使用drawArc方法绘制圆弧,其中设置圆弧的起始度和度范围。可以根据需要调整这些参数来绘制不同的圆弧
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值