CocoaPods trunk is moving to be read-only. Read more on the blog, there are 17 months to go.

UIImageView-AutoAdapter 1.0.3

UIImageView-AutoAdapter 1.0.3

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jan 2016

Maintained by KeyboardToolBar.



  • By
  • Jiar

What's the UIImageView-AutoAdapter

在实际的开发项目中,经常遇到UIImageViewUIImage的大小无法适配的情况,使得显示的图片以拉伸、压缩、旁边留白等形式显示,效果很不理想。UIImageView-AutoAdapter正是为了解决这个问题出现的,实现自动适配UIImage,使得图片以正常的宽高比显示,无拉伸缩放等影响。 UIImageView-AutoAdapter show
上图由两部分组成,左边为xib中图片的显示形式,右边为实际在真机上图片的显示形式。在左边的显示效果中我们可以看到,图片以拉伸或是压缩的形式显示,而右边的显示效果中,图片以理想的效果显示。

最后一张图片由于我在代码中设置了关闭了使用UIImageView-AutoAdapter,因此两边最后一张图片的显示效果一样。

由此可见,使用UIImageView-AutoAdapter即可轻松解决图片适应问题。

How To Get Started

Podfile

platform :ios, '7.0'
pod "UIImageView-AutoAdapter"

如果CocoaPods中无法搜索到UIImageView-AutoAdapter,先尝试使用pod repo update --verbose更新下CocoaPods

Usage

UIImageView-AutoAdapter使用了runtime黑魔法,你不需要进行任何额外的调用就可以直接使用。当然,如果你想让某个UIImageView不使用UIImageView-AutoAdapter,你可以用如下方式为这个UIImageView关闭使用UIImageView-AutoAdapter

#import "KeyboardToolBar.h"

// imageView是UIImageView的实例对象
[imageView setCloseAdapter:YES];

License

UIImageView-AutoAdapter使用了MIT开源协议。