MessengerBubbles

Create ImageView for User or Group like Messenger app.

gif

Example

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

Requirements

Installation

CocoaPods

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

pod 'MessengerBubbles'

Manually

If you prefer not to use any of the aforementioned dependency managers, you can integrate CodableCloudKit into your project manually. Simply drag the Sources Folder into your Xcode project.

Usage

From Storyboard

MessengerBubbles is a subview of UIView

Storyboard

Just create a UIView and replace the Custom Class with MessengerBubbles

You can choose if you want to enable the online bubble indicator, if the user or group is online or not, change the online buble color and border color.

Programmatically

You have many ways to create a MessengerBubbles

public init(size: CGFloat,
            borderColor: UIColor = .white,
            onlineBubbleColor: UIColor = PrivateConstants.onlineBubbleColor,
            enableOnlineBubble: Bool = true,
            isOnline: Bool = false)


public init(images: [UIImage?]?,
            size: CGFloat,
            borderColor: UIColor = .white,
            onlineBubbleColor: UIColor = PrivateConstants.onlineBubbleColor,
            enableOnlineBubble: Bool = true,
            isOnline: Bool = false)

public init(urls: [String?]?,
            size: CGFloat,
            borderColor: UIColor = .white,
            onlineBubbleColor: UIColor = PrivateConstants.onlineBubbleColor,
            enableOnlineBubble: Bool = true,
            isOnline: Bool = false)

Size is always requiered. All others properties have a default value.

MessengerBubbles(size: 60) // With size only

MessengerBubbles(size: 60, borderColor: .blue, 
                 onlineBubbleColor: .yellow,
                 enabledOnlineBubble: false,
                 isOnline: false) // With custom values

MessengerBubbles(images: images,
                 size: 60) // With an array of UIImage at initialization

MessengerBubbles(urls: urls,
                 size: 60) // With an array of String at initialization

You can set images after MessengerBubbles has been created.
If your array contains 1 element, it will create a single bubble.
By the way, if it contains 2 elements or more, it will create 2 bubbles even if it contains more than 2 elements.

public func setImages(with images: [UIImage?]?) // Set images with an array of UIImage
public func setImages(with urls: [String?]?) // Set images with an array of String

let bubble = MessengerBubbles(size: 60)
bubble.setImages(with: images)
//or
bubble.setImages(with: urls)

isOnline and onlineBubbleColor can be changed after initialization

bubble.isOnline = true // or false
bubble.onlineBubbleColor = .black // or whatever you want

Author

Laurent Grondin, [email protected]

GitHub