Giter VIP home page Giter VIP logo

uiimageviewalignedswift's Introduction

UIImageViewAlignedSwift

Version License Platform Carthage compatible

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 8.0+, tvOS 9.0+
  • Swift 4.x

Installation

CocoaPods

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 Podfile:

pod 'UIImageViewAlignedSwift'

Then, run the following command:

$ pod install

Carthage

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 Cartfile:

github "sochalewski/UIImageViewAlignedSwift"

Run carthage update to build the framework and drag the built UIImageViewAlignedSwift.framework into your Xcode project.

What is it?

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 .scaleAspectFit, .scaleAspectFill or .scaleToFill.

It is rewritten to Swift based on original UIImageViewAligned by reydanro.

Why a subclass of UIImageView, and not a standard UIView?

Because there are many cool categories built on top of UIImageView. Subclassing a standard UIView would mean losing them.

For example, AFNetworking's async UIImageView category works perfectly using this container class, and you don't have to worry about a thing.

How does it work?

When initialized, 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 image, contentMode or alignment and the image will reposition itself correctly.

The image property of UIImageViewAligned is overwritten to forward the calls to the inner UIImageView, so you can just drag and drop into your app.

Author

Piotr Sochalewski, sochalewski.github.io

License

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

uiimageviewalignedswift's People

Contributors

benjamindetroch avatar mickmaccallum avatar shanev avatar sochalewski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.