图片自定义圆角

       // 自定义各个顶角的圆角 

  /// 头像

        iconView = UIImageView()

        iconView.frame.size = CGSizeMake(Consts.WIDTH - 10, 170 * Consts.RATE)

        contentView.addSubview(iconView)        

        let maskPath = UIBezierPath(roundedRect: iconView.bounds, byRoundingCorners: [UIRectCorner.TopLeft,UIRectCorner.TopRight], cornerRadii: CGSize(width: 10, height: 10))

        let maskLayer = CAShapeLayer()

        maskLayer.frame = iconView.bounds

        maskLayer.path = maskPath.CGPath        

        iconView.layer.mask = maskLayer

 

   ///UIRectCorner.xxx 用来设置矩形视图某个角为圆角

posted @ 2016-05-09 17:06  madarax  阅读(202)  评论(0)    收藏  举报