项目作者: JNDisrupter

项目描述 :
Multiple images view
高级语言: Swift
项目地址: git://github.com/JNDisrupter/JNMultipleImages.git
创建时间: 2017-09-13T15:36:28Z
项目社区:https://github.com/JNDisrupter/JNMultipleImages

开源协议:MIT License

下载


JNMultipleImages

Build Status
Version
License
Platform

JNMultipleImages can be used to display multiple images in single view, it can be used in a newsfeed or posts. A single post can contain up to 4 displayed images, while showing a number with the remaining images if they are more than 4.

Preview




Requirements

  • iOS 11.0+ / macOS 14.4+
  • Xcode 15.3+
  • Swift 5.10+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

  1. $ gem install cocoapods

To integrate JNMultipleImages into your Xcode project using CocoaPods, specify it in your Podfile:

  1. use_frameworks!
  2. target '<Your Target Name>' do
  3. pod 'JNMultipleImages'
  4. end

Then, run the following command:

  1. $ pod install

Usage

To add JNMultipleImages in interface builder:

  1. Put some UIView and change the class to “JNMultipleImages”

  2. Add refrence for it in the view controller.

  3. Change Attributes:

  • You can change count label attributes by accessing it directly from the JNMultipleImages reference.
  • delegate : this delegate confirm to JNMultipleImagesViewDelegate.
  1. Call setup method:

Setup with JNImage array

  1. setup(images: [JNImage], countLabelPosition: JNMultipleImagesCountLabelPosition = JNMultipleImagesCountLabelPosition.lastItem, placeHolderImage: UIImage? = nil, itemsMargin : CGFloat = 2.0, style: JNMultipleImagesView.style = .collection, cornerRadius: CGFloat = 0)

Setup with array of any which might be Url String or UIImage

  1. func setup(images: [Any], countLabelPosition: JNMultipleImagesCountLabelPosition = JNMultipleImagesCountLabelPosition.lastItem, placeHolderImage: UIImage? = nil, itemsMargin: CGFloat = 2.0, style: JNMultipleImagesView.style = .collection, cornerRadius: CGFloat = 0)
parameters
  • images : The images array to load.
  • countLabelPosition : The position for the count label (Fill view or fill last item).
  • placeHolderImage : The placeholder image to use for failed images.
  • itemsMargin : The margin between items.
  • style : The style of the view, it can be collection or a stack(horizental).
  • cornerRadius : corner radius for images.

The library will adjust the UIImageViews content mode automatically like the follows :

  • If the image dimensions is smaller than the image view dimensions then the content mode is aspectFill
  • If image width and height ratio less than the image view width and height ration then the content mode is aspectFill
  • If the image is landscape and the image height is less than the image view height then the content mode is topRight
  • Other than this it is aspectFit.

Authors

Jayel Zaghmoutt & Mohammad Nabulsi

License

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