Latest 0.3.1-swift3
Homepage https://github.com/paulz/ImageCoordinateSpace
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

Image Coordinate Space

UICoordinateSpace for UIImageView image written in Swift 2

Build Status
Version
License
Platform
Carthage compatible

Usage

Convert CGPoint from image coordinates to view coordinates:

import ImageCoordinateSpace

let imageSpace = imageView.contentSpace()
let imageTopLeft = imageSpace.convertPoint(CGPointZero, toCoordinateSpace: imageView)

Convert CGPoint from view coordinates to image coordinates:

let viewTopLeft = imageSpace.convertPoint(CGPointZero, fromCoordinateSpace: imageView)

Similar conversions are available for CGRect:

let imageRect = CGRect(x: 321, y: 102, width: 63, height: 64)
let viewRect = imageSpace.convertRect(imageRect, toCoordinateSpace: imageView)

and from view coordinates to image coordinates:

let viewRect = CGRect(x: 107, y: 68, width: 21, height: 42.667)
let imageRect = imageSpace.convertRect(viewRect, fromCoordinateSpace: imageView)

Examples

Add positioned image overlay

Open included Xcode Example project to see Xcode Playground: Example/Visual.playground

Demonstrate image ovelay placement

Converting image face detection regions to view touch points

http://stackoverflow.com/questions/12201603/translating-cidetector-face-detection-results-into-uiimageview-coordinates
http://stackoverflow.com/questions/33198266/convert-from-cirectanglefeature-coordinates-to-view-coordinates

Other uses from popular Stackoverflow questions:

Documentation

HeaderDoc is included, see UIImageView+UICoordinateSpace.swift

Installation

CocoaPods

  • add the following line to your Podfile:

    pod 'ImageCoordinateSpace'

  • run pod install

Carthage

  • add to your Cartfile:

    github "paulz/ImageCoordinateSpace"

  • run carthage update
  • link your app with ImageCoordinateSpace.framework from Carthage/Build/iOS folder

Unit tests

To run included unit tests install dependencies via Carthage:

carthage bootstrap

Run tests:

xctool test

Author

Paul Zabelin, https://github.com/paulz

License

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

Latest podspec

{
    "name": "ImageCoordinateSpace-Swift3",
    "cocoapods_version": ">= 0.36",
    "module_name": "ImageCoordinateSpace",
    "version": "0.3.1-swift3",
    "summary": "Convert image coordinates to image view depending on content mode",
    "description": "Convert CGPoint and CGRect between UIImage and UIImageView coordinates respecting UIViewContentMode and using UICoordinateSpace",
    "homepage": "https://github.com/paulz/ImageCoordinateSpace",
    "screenshots": "https://raw.githubusercontent.com/paulz/ImageCoordinateSpace/master/Example/demo.gif",
    "license": "MIT",
    "authors": {
        "Paul Zabelin": "https://github.com/paulz"
    },
    "source": {
        "git": "https://github.com/JulianKniephoff/ImageCoordinateSpace.git",
        "tag": "0.3.1-swift3"
    },
    "social_media_url": "https://twitter.com/iospaulz",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "ImageCoordinateSpace/**/*.{h,swift}",
    "frameworks": "UIKit",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This