Loki 2.0.1

Loki 2.0.1

测试已测试
语言语言 Obj-CObjective C
许可 Apache-2.0
发布最后发布2021 年 6 月

William Towe 维护。



Loki 2.0.1

  • 作者
  • William Towe

Loki

Carthage compatible Version Platform License

Loki 是一个 iOS/macOS/tvOS/watchOS 框架,用于操作 UIImage/NSImage。iOS/macOS/tvOS 上提供了调整大小、着色、突出显示、模糊和调节对比度、亮度和饱和度的方法。由于依赖于 Accelerate 框架,watchOS 上只提供部分方法。

还提供了一些从 PDF 源文档渲染图像的方法,给定特定的宽度、高度或大小,只要提供了 PDF 名称、包或 URL。

安装

您可以使用 cocoapodsCarthage 或作为框架来安装 Loki

依赖项

Apple

  • AccelerateiOSmacOStvOS

示例

突出显示图像

// assume image exists
UIImage *image = ...;

// the image will have a partially transparent orange tint applied over it
image = [image KLO_imageByHighlightingWithColor:[UIColor.orangeColor colorWithAlphaComponent:0.25]];

着色图像

// assume image exists
UIImage *image = ...;

// the image will have its opaque pixels colored orange
image = [image KLO_imageByTintingWithColor:UIColor.orangeColor];

调整图像大小

// assume image exists
UIImage *image = ...;

// the image will be resized to the provided size and its aspect ratio will be maintained
image = [image KLO_imageByResizingToSize:CGSizeMake(25, 25) maintainAspectRatio:YES];

模糊图像

// assume image exists
UIImage *image = ...;

// the image will be blurred using a box blur with the provided radius
image = [image KLO_imageByBlurringWithRadius:25.0];

生成 PDF 图像

// image with the provided name in the main bundle scaled to the provided width and automatically determined height
UIImage *image = [UIImage KLO_imageWithPDFNamed:@"image" width:100];
// image with the provided name in the main bundle scaled to the provided height and automatically determined width
UIImage *image = [UIImage KLO_imageWithPDFNamed:@"image" height:100];
// image with the provided name in the main bundle scaled to the provided size
UIImage *image = [UIImage KLO_imageWithPDFNamed:@"image" size:CGSizeMake(25, 25)];

还有许多其他与 PDF 相关的方法。请参阅 UIImage+KLOPDFExtensions.hNSImage+KLOPDFExtensions.h,查看所有方法列表。

示例

工作空间中的各种示例目标提供了进一步展示图像和PDF相关方法的实例。