Latest 0.1.2
Homepage https://github.com/huang-kun/UIImageView_YJ
License MIT
Platforms ios 6.0, requires ARC
Frameworks UIKit
Authors

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, [email protected]

License

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

Latest podspec

{
    "name": "UIImageView_YJ",
    "version": "0.1.2",
    "summary": "UIImageView_YJ is a UIImageView class extension that can use new contentMode to display it's contents.",
    "description": "UIImageView_YJ is a UIImageView class extension that can use new contentMode to display it's contents. Simply using yj_contentMode instead of contentMode.",
    "homepage": "https://github.com/huang-kun/UIImageView_YJ",
    "license": "MIT",
    "authors": {
        "huang-kun": "[email protected]"
    },
    "source": {
        "git": "https://github.com/huang-kun/UIImageView_YJ.git",
        "tag": "0.1.2"
    },
    "platforms": {
        "ios": "6.0"
    },
    "requires_arc": true,
    "source_files": "UIImageView_YJ/**/*",
    "public_header_files": "UIImageView_YJ/**/*.h",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This