hgplaceholders

Introduction

Welcome to the documentation for HGPlaceholders – a library that provides functionality for managing placeholders in your iOS applications. With HGPlaceholders, developers can easily handle scenarios where content is being loaded or updated, improving the user experience.

Features

  • Efficient handling of placeholder states
  • Customizable appearance for placeholders
  • Support for different types of placeholders
  • Flexible integration with existing UI components
  • Seamless integration with popular networking libraries

Installation

To install HGPlaceholders in your iOS project, you can choose one of the following methods:

CocoaPods

Add the following line to your Podfile:

“`ruby
pod ‘HGPlaceholders’
“`

Then, run the command:

“`bash
$ pod install
“`

Manual Installation

  1. Download the latest version of HGPlaceholders.
  2. Drag and drop the HGPlaceholders.xcodeproj into your Xcode project.
  3. In your project’s settings, select your target and go to General > Frameworks, Libraries, and Embedded Content.
  4. Add HGPlaceholders.framework using the ‘+’ button.

Usage

To start using HGPlaceholders in your iOS application, follow these steps:

Import

In the file where you want to use HGPlaceholders, import the framework:

“`swift
import HGPlaceholders
“`

Create a PlaceholderManager

Create an instance of PlaceholderManager to handle your placeholders. Make sure to configure your PlaceholderManager according to your app’s requirements.

“`swift
let placeholderManager = PlaceholderManager()
placeholderManager.configure(with: .defaultConfiguration) // Customize as needed
“`

Displaying a Placeholder

Use the showLoadingPlaceholder(on:) method of the PlaceholderManager to display a loading placeholder on a specific view:

“`swift
placeholderManager.showLoadingPlaceholder(on: myView)
“`

Updating a Placeholder

If you need to update the state or appearance of a placeholder, you can use the update(placeholder:) method:

“`swift
placeholderManager.update(placeholder: myPlaceholder)
“`

Hiding a Placeholder

When your content has finished loading and is ready to be displayed, you can hide the placeholder using the hidePlaceholder(on:) method:

“`swift
placeholderManager.hidePlaceholder(on: myView)
“`

Customizing Placeholders

HGPlaceholders provides various customization options to match your app’s design. You can configure global placeholder styles using the PlaceholderConfiguration struct:

“`swift
let customConfiguration = PlaceholderConfiguration(
loadingViewClass: MyCustomLoadingView.self,
errorViewClass: MyCustomErrorView.self,
emptyViewClass: MyCustomEmptyView.self
)
placeholderManager.configure(with: customConfiguration)
“`

Conclusion

HGPlaceholders simplifies the management of placeholders in your iOS app, providing an intuitive way to handle loading, error, or empty states. By using HGPlaceholders, you can enhance the user experience and ensure a seamless display of content.

Have Questions?

If you have any questions, feel free to reach out to our support team at support@hgplaceholders.com. We’re here to help!