• IOS把图片做成圆形效果


      利用CAShapeLayer能够制作出随意的几何图形,把它作为UIImageView的遮罩,达到把图片做成圆形效果。

     

     

     imgView =  [[UIImageView alloc]initWithFrame:CGRectMake(10, 35, 80, 80)];
        imgView.image = [UIImage imageNamed:@"ma.jpg"];
        UIBezierPath* path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(40, 40) radius:40 startAngle:0 endAngle:2*M_PI clockwise:YES];
        CAShapeLayer* shape = [CAShapeLayer layer];
        shape.path = path.CGPath;
        imgView.layer.mask = shape;
        [self.view addSubview:imgView];

    以下在补充一个方法:

    [m_photo.layer setCornerRadius:CGRectGetHeight([m_photo bounds]) / 2];//设置圆形半径
        m_photo.layer.masksToBounds = YES;
        m_photo.layer.borderWidth = 1;//设置外环宽度
        m_photo.layer.borderColor = [[UIColor greenColor] CGColor];//设置外环颜色
        m_photo.layer.contents = (id)[[UIImage imageNamed:@"index.png"] CGImage];//设置图片


  • 相关阅读:
    JVM系列-001-JVM监控工具
    Java8-CompletableFuture
    Java8-ConcurrentUtils
    Java8-LongAccumulator
    Java8-Atomic
    Java8-ConcurrentHashMap
    Java8-Synchronized-No.02
    Java8-Synchronized-No.01
    Java8-Executors-No.03
    Java8-Executors-No.02
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/6723772.html
Copyright © 2020-2023  润新知