Skip to content

Message that slides down from the top of the screen. Written in Swift. Uses and requires AutoLayout. Optionally disappears automatically after a delay.

License

Notifications You must be signed in to change notification settings

jonathan-stone/slidingmessage

Repository files navigation

slidingmessage

===========

slidingmessage is a simple message view that slides down from the top of its parent. It's a way of displaying error messages or other important notifications in an iOS app, using an animation to draw the user's attention. It can be configured to slide down to just under any control in a view, for example, under a text field with invalid input.

  • Requires AutoLayout.
  • Tapping anywhere closes the view. An X graphic is included to give users the hint that they can close it.
  • Optionally closes automatically after N seconds.

Demo Video

Here's the demo app in action. Note that you can change the color, the font, height, and of course the text content of the sliding message.

Video Walkthrough

Example usage:


Creating the control:

self.errorNotification = SlidingMessage(
    parentView: self.view,
    autoHideDelaySeconds: 5,
    backgroundColor: UIColor.redColor(),
    foregroundColor: UIColor.whiteColor(),
    minimumHeight: 100,
    positionBelowControl: self.requiredTextField,   // can be any UIControl
    font: UIFont.preferredFontForTextStyle(UIFontTextStyleBody))

Showing the message:


@IBAction func buttonPressed(sender: AnyObject)
{
    if (self.requiredTextField.Text.isEmpty)
    {
        self.errorNotification?.show("You have to enter something!")
    }
}

Demo project

Can be found in slidingMessageDemo.

About

Message that slides down from the top of the screen. Written in Swift. Uses and requires AutoLayout. Optionally disappears automatically after a delay.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published