Skip to content

Latest commit

 

History

History
190 lines (143 loc) · 5.03 KB

README.md

File metadata and controls

190 lines (143 loc) · 5.03 KB

Leon

leon is a ios library written with swift to enable developer to handle show images with animation and with more gesture

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Leon into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Leon', '~> 0.0.8'

Usage

How to get image frame

if container of image is UIView or UIStackView

// get point of image
let point = imageView.convert(imageView.bounds.origin, to: self.view /* view is parent view in viewController */ )
// get size of image
let size = CGSize(width: imageView.frame.width , height: imageView.frame.height)
// get frame of image 
let frame = CGRect(origin: point , size: size )

There are 6 init funtions in Leon Images

First init

// 1- first init
let vc = LeonImages(image: imageView.image!)
self.present(vc , animated: true )
  • image: just pass image in imegView without starter animation
  • use this init if u have image as just UIImage and don't need to load image from web







Second init

//2- second init
let vc = LeonImages(imageURL: String )
self.present(vc , animated: true )
  • imageURL: is a string url of image to load from web without starter animation
  • use this init if you don't want start animation




Third init

// 3- third init
let vc = LeonImages(listImagesURL: [Any] , index : 2 )
self.present(vc , animated: true )
  • listImagesURL : an array that contain two type of images
    • array may contain string url image to load from web
    • array may contain UIImage to just set this image in imageView in LeonImages
  • index ( optional -> default value = 0 ) : the index for starter image in array




Fourth init

// 4- fourth init
let vc = LeonImages(startFrame: imageView.frame , thumbnail: imageView.image! , imageURL: String )
self.present(vc , animated: true )
  • Use this init to start Leon with animation from start fram to center of screen
  • startFrame : init frame of image to start frame from this point
  • thumbnail : init UIImage in imageView untile animation finished
  • imageURL : start load image after animation finish




Fifth init

// 5- fifth init
let vc = LeonImages(startFrame: imageView.frame , thumbnail: imageView.image! )
self.present(vc , animated: true )
  • Use this init to start Leon with animation from start fram to center of screen
  • startFrame : init frame of image to start frame from this point
  • thumbnail : init UIImage in imageView untile animation finished




Sixth init

// 6- Six init
let vc = LeonImages(startFrame: imageView.frame , thumbnail: imageView.image!, listImagesURL: [Any] , index : 2 )
self.present(vc , animated: true )
  • startFrame : init frame of image to start frame from this point
  • thumbnail : init UIImage in imageView untile animation finished
  • listImagesURL : an array that contain two type of images
  • array may contain string url image to load from web
  • array may contain UIImage to just set this image in imageView in LeonImages
  • index ( optional -> default value = 0 ) : the index for starter image in array




Features

  • change error message when loading failure (default value : "Error loading, tap to reload" )
let vc = // use init LeonImages
vc.errorMessage = "write your message"
  • enable / disable tap to reload when loadin failure
let vc = // use init LeonImages
vc.tapToReload = true

  • enable / disable close button (default value : true)
let vc = // use init LeonImages
vc.showCloseButton = false
  • dismiss image by panGesture

  • zoom image with pinch gesture

  • zoom image with double tap

  • create custom View Controller extended LeonImages

    Example of CustomLeonImages

    Custom Leon Images

Author

Yusef Naser

License

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