Skip to content

baekteun/BTImageView

Repository files navigation

BTImageView

Version License Platform

Requirements

  • iOS 9.0 or higher
  • Swift 5.0

Usage

import

import BTImageView

Use

Storyboard

Add a custom view to the storyboard and set its class to "BTImageView".

Programmatically

Initialize BTImageView programmatically

let imageView = BTImageView()
view.addSubView(imageView)

Example

imageView.aligns = [2, 3]
imageView.axis = .vertical
imageView.setImages(images: [
    .init(systemName: "1.circle") ?? .init(),
    ...
    .init(systemName: "9.circle") ?? .init(),
])

Result:

Ex1

imageView.aligns: [1, 2]
imageView.axis = .horizontal
imageView.setImages(images: [
    .init(systemName: "1.circle") ?? .init(),
    ...
    .init(systemName: "9.circle") ?? .init(),
])

Result:

Ex2

imageView.aligns: [2, 3, 2]
imageView.axis = .vertical
imageView.setImages(images: [
    .init(systemName: "1.circle") ?? .init(),
    ...
    .init(systemName: "9.circle") ?? .init(),    
])

Result:

Ex3

BTImageView

Properties

var imageViews: [UIImaeView] // All UIImageViews in BTImageView. (Default: [])

var images: [UIImage] // All UIImages in BTImageView. (Default: [])

var aligns: [Int] // Item align in BTImageView. (Default: [1])

var axis: NSLayoutConstraint.Axis // ImageViews's direction where its pile up (Default: .horizontal)

var spacing: CGFloat // The spacing of the imageViews. (Default: 5)

var cornerRadius: CGFloat // The ImageView's cornerRadius (Default: 5)

Methods

func addImage(image: UIImage)

Add a image with UIImage into the BTImageView

func addImage(url: String)

Add a image with URLstring into the BTImageView

func setImages(images: [UIImage])

Set images with UIImages of the BTImageView

func setImages(urls: [String])

Set images with URLstrings of the BTImageView

func removeFirstImage()
func removeLastImage()
func removeImage(at index: Int)
func removeAllImage()

Remove image from the BTImageViewg

Installation

Swift Package Manager

BTImageView is available througb SPM. To install it, simply add the following line to your Package.swift:

// Package.swift

dependencies: [
    .package(url: "https://github.com/baekteun/BTImageView", from: "1.1.2")
]

Cocoapods

BTImageView is available through CocoaPods. To install it, simply add the following line to your Podfile:

# Podfile

pod 'BTImageView'

Author

baekteun, baegteun@gmail.com

License

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