To run the example project, clone the repo, and run
pod install from the Example directory first.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate UIImageViewAlignedSwift into your Xcode project using CocoaPods, specify it in your
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update $ brew install carthage
To integrate UIImageViewAlignedSwift into your Xcode project using Carthage, specify it in your
carthage update to build the framework and drag the built
UIImageViewAlignedSwift.framework into your Xcode project.
It is a subclass of
UIImageView that allows you to customize the alignment of the displayed image inside the view's frame.
This works even if the
contentMode is set to
It is rewritten to Swift based on original UIImageViewAligned by reydanro.
Because there are many cool categories built on top of
UIImageView. Subclassing a standard
UIView would mean losing them.
UIImageView category works perfectly using this container class, and you don't have to worry about a thing.
UIImageViewAligned will create a inner
UIImageView which will actually hold the image displayed.
The main class then just repositions this inner
UIImageView to achieve your desired alignment.
At runtime, you can change the
alignment and the image will reposition itself correctly.
image property of
UIImageViewAligned is overwritten to forward the calls to the inner
UIImageView, so you can just drag and drop into your app.
Piotr Sochalewski, sochalewski.github.io
UIImageViewAlignedSwift is available under the MIT license. See the LICENSE file for more info.
|Last commit: 2 weeks ago|