【Swift】iOS裁剪或者压缩后出现的白边问题
2016-06-15 13:03
603 查看
只需要将所有的CGFloat转化为NSInteger即可
func imageScaleSize(newSize:
CGSize) -> UIImage{
let width =
NSInteger(newSize.width)
let height =
NSInteger(newSize.height)
UIGraphicsBeginImageContext(CGSize(width: width, height: height));
self.drawInRect(CGRect(x:
0, y: 0, width: width, height: height))
let newImage =
UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext();
return newImage;
}
func imageScaleSize(newSize:
CGSize) -> UIImage{
let width =
NSInteger(newSize.width)
let height =
NSInteger(newSize.height)
UIGraphicsBeginImageContext(CGSize(width: width, height: height));
self.drawInRect(CGRect(x:
0, y: 0, width: width, height: height))
let newImage =
UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext();
return newImage;
}
相关文章推荐
- Swift基本语法
- swift获取View所在ViewController的控制器对象
- swift 值引用
- 画空心圆
- Swift中属性Properties
- WWDC2016-session402-whatsNewInSwift3
- NSJSONSerialization类抛出异常处理(swift)
- Swift 中的过滤器详解
- Swift 语言的设计错误有哪些?
- Swift 数组、字符串、集合与字典详解
- Swift-Xcode真机运行出现Reason: image not found错误
- swift实现代理
- swift 写分类
- swift自定义方法添加监听方法参数
- swift自定义按钮文本和图片的位置
- swift中如何写π
- swift统一设置导航条按钮属性
- swift添加导航条按钮,不生效的原因
- swift设置导航条左边的按钮
- swift可以直接修改控件的frame