ios - 使用使用 capInsets 增长图像的 CoreGraphics 绘制 UIImage

标签 ios uiimage core-graphics cgimage xcasset

假设我在 Images.xcassets 中存储了一张切片的图像;即它的 capInsets 属性已设置,我想在 CoreGraphics 中绘制比其实际大小更大的图像。我该怎么做?

我是否必须使用 capInsets 属性手动将图像分成 9 个部分,然后手动增长/拉伸(stretch)这 9 个部分,还是有更简单的方法?

最佳答案

    UIGraphicsBeginImageContext(litView.layer.frame.size);
    [litImg drawInRect:litView.layer.frame];
    UIImage *resizedImg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

关于ios - 使用使用 capInsets 增长图像的 CoreGraphics 绘制 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22846903/

相关文章:

iphone - 如何在 UIImageView 中为图像应用宽高比后知道图像大小

iOS 应用程序因频繁绘制上下文图像而崩溃

ios - 在 UIImage 上绘制删除透视,露出下面的 UIImage 图层

iphone - 如何移动 CGPath 而不创建新的

javascript - 当 textarea 聚焦时防止移动 safari 滚动页面

ios - 如何在 iPhone 的类似数据网格的表格中显示和输入大量数据

ios - 带有自定义 UITableView 单元格图像的 SDWebImage

ios - WatchKit - iPhone 不可用屏幕

ios - 是否可以刷新 UITableViewCell 中的一个 View

ios - 将 UIImage 数据上传到服务器获取内存峰值?