Skip to content

UIImageView_YJ is a UIImageView class extension that can use new contentMode to display it's contents.

License

Notifications You must be signed in to change notification settings

emmet7life/UIImageView_YJ

 
 

Repository files navigation

UIImageView_YJ

CI Status Version License Platform

Usage

UIViewContentMode

When you display an image in a UIImageView. The UIViewContentMode decides the rule of displaying.

e.g. To make the image scale aspect fit in the imageView, just set UIImageView's contentMode property to UIViewContentModeScaleAspectFit.

imageView.contentMode = UIViewContentModeScaleAspectFit;

fit

To make the image align top of the imageView, just set UIImageView's contentMode property to UIViewContentModeTop. (The image itself is big!)

imageView.contentMode = UIViewContentModeTop;

Top

However, what if you would like to make it both fit in the imageView and then align top ? Obviously There is no option like UIViewContentModeScaleAspectFitTop provided by the UIViewContentMode enum type.


YJViewContentMode

This is a new enum type defined by NS_OPTIONS macro. To achieve both fit and align top effect, just set it's yj_contentMode property:

imageView.yj_contentMode = YJViewContentModeScaleAspectFit | YJViewContentModeTop;

Write one line of code, you get the result like this:

Fit_Top

There are a lot of combinations you can specify like (Fit | Top | Left). Once your combinations encounter the conflict, e.g. (Fit | Fill) or (Top | bottom), it automatically filtering the result by giving up some of the options.


Requirements

ARC enabled

Installation

UIImageView_YJ is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "UIImageView_YJ"

Author

huang-kun, jack-huang-developer@foxmail.com

License

UIImageView_YJ is available under the MIT license. See the LICENSE file for more info.

About

UIImageView_YJ is a UIImageView class extension that can use new contentMode to display it's contents.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 44.4%
  • Objective-C 43.1%
  • C 8.1%
  • Ruby 4.4%