Convert Figma logo to code with AI

KrauseFx logoTSMessages

💌 Easy to use and customizable messages/notifications for iOS à la Tweetbot

4,876
721
4,876
96

Top Related Projects

MBProgressHUD + Customizations

A drop-in replacement for UILabel that supports attributes, data detectors, links, and more

ProgressHUD is a lightweight and easy-to-use HUD for iOS. Over 5000+ animations. ‼️

A clean and lightweight progress HUD for your iOS and tvOS app.

iOS-based charting library for both line and bar graphs.

A delightful networking framework for iOS, macOS, watchOS, and tvOS.

Quick Overview

TSMessages is an iOS library that provides easy-to-use, customizable in-app notifications and alerts. It allows developers to display various types of messages as overlays on top of the current view, with options for different styles, animations, and durations.

Pros

  • Easy integration and usage in iOS projects
  • Highly customizable appearance and behavior
  • Supports different message types (success, error, warning, etc.)
  • Smooth animations and auto-dismissal options

Cons

  • Limited to iOS platform only
  • May require additional setup for complex layouts
  • Documentation could be more comprehensive
  • Not actively maintained (last update was several years ago)

Code Examples

  1. Displaying a simple success message:
TSMessage.showNotification(in: self.view, title: "Success", subtitle: "Your action was successful", type: .success)
  1. Showing a custom-styled warning message:
let messageView = TSMessageView(title: "Warning", subtitle: "Please check your input", type: .warning)
messageView.backgroundColor = UIColor.orange
messageView.titleTextColor = UIColor.white
TSMessage.showNotification(with: messageView)
  1. Displaying a message with a custom duration and completion handler:
TSMessage.showNotification(in: self.view, title: "Processing", subtitle: "Please wait...", type: .message, duration: 5.0, callback: {
    print("Message dismissed")
})

Getting Started

  1. Install TSMessages using CocoaPods by adding the following to your Podfile:
pod 'TSMessages'
  1. Import TSMessages in your Swift file:
import TSMessages
  1. Use TSMessage to display notifications:
TSMessage.showNotification(in: self.view, title: "Hello", subtitle: "Welcome to TSMessages", type: .success)

Competitor Comparisons

MBProgressHUD + Customizations

Pros of MBProgressHUD

  • Lightweight and easy to implement
  • Highly customizable with various styles and animations
  • Widely adopted and well-maintained

Cons of MBProgressHUD

  • Limited to progress indicators and simple messages
  • Less visually appealing out-of-the-box compared to TSMessages
  • Requires more custom code for complex notifications

Code Comparison

MBProgressHUD:

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.label.text = @"Some message";
[hud hideAnimated:YES afterDelay:3.0f];

TSMessages:

TSMessage.showNotification(
    withTitle: "Title",
    subtitle: "Some message",
    type: .success
)

Summary

MBProgressHUD is a lightweight, customizable progress indicator library, while TSMessages focuses on more visually appealing, pre-styled notifications. MBProgressHUD is better suited for simple loading indicators and progress updates, whereas TSMessages excels in displaying various types of notifications with rich styling options. The choice between the two depends on the specific needs of your project and the desired visual aesthetics.

A drop-in replacement for UILabel that supports attributes, data detectors, links, and more

Pros of TTTAttributedLabel

  • More focused on rich text rendering and styling
  • Supports CoreText attributes for advanced text formatting
  • Better suited for complex text layouts and inline attachments

Cons of TTTAttributedLabel

  • Limited to label functionality, not a full messaging system
  • Requires more manual configuration for advanced features
  • Less suitable for creating notification-style messages

Code Comparison

TTTAttributedLabel:

TTTAttributedLabel *label = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero];
label.font = [UIFont systemFontOfSize:14];
label.textColor = [UIColor darkGrayColor];
label.lineBreakMode = NSLineBreakByWordWrapping;
label.numberOfLines = 0;

TSMessages:

[TSMessage showNotificationInViewController:self
                                      title:@"Title"
                                   subtitle:@"Subtitle"
                                      image:nil
                                       type:TSMessageNotificationTypeSuccess
                                   duration:TSMessageNotificationDurationAutomatic
                                   callback:nil
                                buttonTitle:nil
                             buttonCallback:nil
                                 atPosition:TSMessageNotificationPositionTop
                       canBeDismissedByUser:YES];

TSMessages is designed for creating and displaying notification-style messages with various customization options, while TTTAttributedLabel focuses on advanced text rendering and styling for labels. TSMessages offers a more comprehensive solution for in-app notifications, whereas TTTAttributedLabel provides greater control over text appearance and layout within a label context.

ProgressHUD is a lightweight and easy-to-use HUD for iOS. Over 5000+ animations. ‼️

Pros of ProgressHUD

  • Simpler and more lightweight, focusing solely on progress indicators and HUDs
  • Easier to implement for basic loading and progress scenarios
  • Supports both Swift and Objective-C

Cons of ProgressHUD

  • Less customizable in terms of appearance and animations
  • Limited to HUD-style notifications, lacking support for banner-style messages
  • Fewer options for message types and styles

Code Comparison

TSMessages:

TSMessage.showNotification(in: self.view, title: "Title", subtitle: "Message", type: .success)

ProgressHUD:

ProgressHUD.show("Loading...")
ProgressHUD.dismiss()

Key Differences

TSMessages is a more comprehensive notification library, offering various styles and customization options for displaying messages. It's better suited for applications requiring diverse notification types and appearances.

ProgressHUD, on the other hand, is more focused on providing simple progress indicators and HUDs. It's ideal for applications that primarily need loading indicators and basic message displays.

While TSMessages excels in versatility and customization, ProgressHUD shines in simplicity and ease of use for straightforward progress and loading scenarios.

A clean and lightweight progress HUD for your iOS and tvOS app.

Pros of SVProgressHUD

  • Lightweight and easy to integrate
  • Supports various styles of HUDs (progress, success, error, etc.)
  • Highly customizable appearance and behavior

Cons of SVProgressHUD

  • Limited to displaying HUDs in the center of the screen
  • Lacks advanced notification features like custom layouts or multiple messages

Code Comparison

SVProgressHUD:

SVProgressHUD.show()
SVProgressHUD.showProgress(0.5)
SVProgressHUD.showSuccess(withStatus: "Done!")
SVProgressHUD.dismiss()

TSMessages:

TSMessage.showNotification(in: self.view, title: "Title", subtitle: "Message")
TSMessage.showNotification(in: self.view, title: "Success", subtitle: "Operation completed", type: .success)
TSMessage.dismissActiveNotification()

Key Differences

  • SVProgressHUD focuses on centered, modal-style progress indicators and status messages
  • TSMessages provides more flexible, customizable notifications that can be displayed at various screen positions
  • SVProgressHUD is better suited for simple loading indicators, while TSMessages excels at presenting informative alerts and notifications
  • TSMessages offers more advanced customization options for notification appearance and behavior

Both libraries serve different purposes and can be used in conjunction depending on the specific needs of your iOS application.

iOS-based charting library for both line and bar graphs.

Pros of JBChartView

  • Specialized in creating interactive charts and graphs
  • Offers a variety of chart types (line, bar, etc.) with customization options
  • Lightweight and easy to integrate into iOS projects

Cons of JBChartView

  • Limited to chart-related functionality
  • May require additional libraries for more complex data visualization needs
  • Less actively maintained compared to TSMessages

Code Comparison

TSMessages (for displaying custom notifications):

TSMessage.showNotification(
    withTitle: "Success",
    subtitle: "Your message was sent successfully!",
    type: .success
)

JBChartView (for creating a line chart):

let chartView = JBLineChartView()
chartView.dataSource = self
chartView.delegate = self
view.addSubview(chartView)

Summary

TSMessages focuses on displaying customizable in-app notifications, while JBChartView specializes in creating interactive charts. TSMessages is more versatile for general app messaging, whereas JBChartView excels in data visualization. The choice between the two depends on the specific needs of your project: messaging and notifications (TSMessages) or chart creation (JBChartView).

A delightful networking framework for iOS, macOS, watchOS, and tvOS.

Pros of AFNetworking

  • Comprehensive networking library with support for various HTTP methods and protocols
  • Extensive documentation and large community support
  • Modular architecture allowing for easy customization and extension

Cons of AFNetworking

  • Larger codebase and potential overhead for simpler projects
  • Steeper learning curve for beginners due to its extensive feature set
  • May require more frequent updates to keep up with iOS SDK changes

Code Comparison

AFNetworking:

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:@"https://api.example.com/data" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    NSLog(@"Error: %@", error);
}];

TSMessages:

[TSMessage showNotificationInViewController:self
                                      title:@"Title"
                                   subtitle:@"Subtitle"
                                      image:nil
                                       type:TSMessageNotificationTypeSuccess
                                   duration:TSMessageNotificationDurationAutomatic
                                   callback:nil
                                buttonTitle:nil
                             buttonCallback:nil
                                 atPosition:TSMessageNotificationPositionTop
                       canBeDismissedByUser:YES];

Summary

AFNetworking is a powerful networking library for iOS and macOS, offering extensive features for HTTP requests and responses. TSMessages, on the other hand, is focused on displaying custom in-app notifications. While AFNetworking provides comprehensive networking capabilities, TSMessages excels in creating visually appealing and customizable notifications within an application.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Notice: TSMessages is no longer being maintained/updated. We recommend everyone migrate to RMessage.

This repository will be kept as is for those who want to continue using TSMessages or are in the process of migrating. If an issue you submitted to TSMessages still applies to RMessage feel free to create a new issue in RMessage's repository.

If your project is Swift based, you might want to check out SwiftMessages, which offers the same features, but is written completely in Swift.

TSMessages

This library provides an easy to use class to show little notification views on the top of the screen. (à la Tweetbot).

Twitter: @KauseFx Version License Platform

The notification moves from the top of the screen underneath the navigation bar and stays there for a few seconds, depending on the length of the displayed text. To dismiss a notification before the time runs out, the user can swipe it to the top or just tap it.

There are 4 different types already set up for you: Success, Error, Warning, Message (take a look at the screenshots)

It is very easy to add new notification types with a different design. Add the new type to the notificationType enum, add the needed design properties to the configuration file and set the name of the theme (used in the config file and images) in TSMessagesView.m inside the switch case.

Take a look at the Example project to see how to use this library. You have to open the workspace, not the project file, since the Example project uses cocoapods.

Get in contact with the developer on Twitter: KrauseFx (Felix Krause)

Screenshots

Installation

From CocoaPods

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

pod "TSMessages"

Manually

Copy the source files TSMessageView and TSMessage into your project. Also copy the TSMessagesDesignDefault.json.

Usage

To show notifications use the following code:

    [TSMessage showNotificationWithTitle:@"Your Title"
                                subtitle:@"A description"
                                    type:TSMessageNotificationTypeError];


    // Add a button inside the message
    [TSMessage showNotificationInViewController:self
                                          title:@"Update available"
                                       subtitle:@"Please update the app"
                                          image:nil
                                           type:TSMessageNotificationTypeMessage
                                       duration:TSMessageNotificationDurationAutomatic
                                       callback:nil
                                    buttonTitle:@"Update"
                                 buttonCallback:^{
                                     NSLog(@"User tapped the button");
                                 }
                                     atPosition:TSMessageNotificationPositionTop
                           canBeDismissedByUser:YES];


    // Use a custom design file
    [TSMessage addCustomDesignFromFileWithName:@"AlternativeDesign.json"];

You can define a default view controller in which the notifications should be displayed:

   [TSMessage setDefaultViewController:myNavController];

You can define a default view controller in which the notifications should be displayed:

   [TSMessage setDelegate:self];
   
   ...
   
   - (CGFloat)messageLocationOfMessageView:(TSMessageView *)messageView
   {
    return messageView.viewController...; // any calculation here
   }

You can customize a message view, right before it's displayed, like setting an alpha value, or adding a custom subview

   [TSMessage setDelegate:self];
   
   ...
   
   - (void)customizeMessageView:(TSMessageView *)messageView
   {
      messageView.alpha = 0.4;
      [messageView addSubview:...];
   }

You can customize message view elements using UIAppearance

#import <TSMessages/TSMessageView.h>
@implementation TSAppDelegate
....

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//If you want you can overidde some properties using UIAppearance
[[TSMessageView appearance] setTitleFont:[UIFont boldSystemFontOfSize:6]];
[[TSMessageView appearance] setTitleTextColor:[UIColor redColor]];
[[TSMessageView appearance] setContentFont:[UIFont boldSystemFontOfSize:10]];
[[TSMessageView appearance]setContentTextColor:[UIColor greenColor]];
[[TSMessageView appearance]setErrorIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
[[TSMessageView appearance]setSuccessIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
[[TSMessageView appearance]setMessageIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
[[TSMessageView appearance]setWarningIcon:[UIImage imageNamed:@"NotificationButtonBackground"]];
//End of override

return YES;
}

The following properties can be set when creating a new notification:

  • viewController: The view controller to show the notification in. This might be the navigation controller.
  • title: The title of the notification view
  • subtitle: The text that is displayed underneath the title (optional)
  • image: A custom icon image that is used instead of the default one (optional)
  • type: The notification type (Message, Warning, Error, Success)
  • duration: The duration the notification should be displayed
  • callback: The block that should be executed, when the user dismissed the message by tapping on it or swiping it to the top.

Except the title and the notification type, all of the listed values are optional

If you don't want a detailed description (the text underneath the title) you don't need to set one. The notification will automatically resize itself properly.

License

TSMessages is available under the MIT license. See the LICENSE file for more information.

Recent Changes

Can be found in the releases section of this repo.