zoukankan      html  css  js  c++  java
  • 一个简单的创建圆角图像的UIImage扩展实现

    - (UIImage *)roundedCornerImageWithCornerRadius:(CGFloat)cornerRadius { CGFloat w = self.size.width; CGFloat h = self.size.height; CGFloat scale = [UIScreen mainScreen].scale; // 防止圆角半径小于0,或者大于宽/高中较小值的一半。 if (cornerRadius < 0) cornerRadius = 0; else if (cornerRadius > MIN(w, h)) cornerRadius = MIN(w, h) / 2.; UIImage *image = nil; CGRect imageFrame = CGRectMake(0., 0., w, h); UIGraphicsBeginImageContextWithOptions(self.size, NO, scale); [[UIBezierPath bezierPathWithRoundedRect:imageFrame cornerRadius:cornerRadius] addClip]; [self drawInRect:imageFrame]; image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }

     

  • 相关阅读:
    Java面向对象知识点总结
    JAVA编程必学必会单词集(1)
    Linux 帮助命令
    学习笔记
    day4
    复习
    day5
    day04
    day3
    day02
  • 原文地址:https://www.cnblogs.com/yjg2014/p/4086949.html
Copyright © 2011-2022 走看看